책 N권의 좌우 순서를 뒤집힘을 구분하지 않고 알아내야 하는 인터랙티브 문제로, 주어진 부분집합을 통째로 집어내는 데 필요한 최소 연속 구간 수를 묻는 질의를 20000번까지 보낼 수 있다.
어려움8완전 탐색구현그리디아직 제출이 없습니다시간 제한2초메모리 제한512 MBAfter several hundred years had passed, JOI city became a ruined city. IOI-chan, an explorer, is now exploring the area where the library was built. According to the results of exploration, the following are known:
Unfortunately, IOI-chan could not find old books in the library. But she found a machine which managed operations of the bookshelf of the library. If we specify one or more than one books by their numbers and send a query to the machine, it answers the minimum number of operations required to take only these books from the bookshelf.
IOI-chan wants to know the order of the books in the bookshelf by sending queries to the machine. However, because the answers from the machine would be the same if the order of the N books are reversed, she does not need to specify whether the books were placed from left to right or from right to left.
Because the machine is old, she can send at most 20 000 queries to the machine.
Write a program which specifies the order of the books in the bookshelf by sending at most 20 000 queries to the machine. It is not necessary to specify whether the books were placed from left to right or from right to left.