Library 3
시간 제한1초메모리 제한1024 MB
주어진 배열을 올바른 배열로 되돌리는 데 필요한 교환 연산 횟수를 알려주는 오라클에 최대 5000번 질의해 숨겨진 올바른 배열을 알아낸다.
문제
After 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:
- There were a horizontal bookshelf in the library of JOI city. It had places in a line to put a book, numbered from to from left to right. Exactly one book could be placed at each place.
- There were books in the bookshelf. The books were numbered from to .
- The arrangement of books is the way to place all the books at the places.
- There was correct arrangement of the books, and the book () was placed at place in the correct arrangement. Provided that is all different.
It often happens that the arrangement of the books changes. We know that in this library, the books were put back in the correct arrangement by repeating the following operation.
operation Let book be the leftmost book among the books that the place of it differs from the place of the correct arrangement. Also let book be the book in the current arrangement at the place where book is placed in the correct arrangement. Swap the places of book and book .
Although IOI-chan found the old books of the library, she could not know the corrent arrangement. But she found an old machine which managed operations of the bookshelf of the library. If we specify the arrangement of the books and send a query to the machine, it answers the number of operations required to put back all the books in the correct arrangement. IOI-chan wants to know the correct arrangement of the books by sending queries to the machine. Because the machine is old, she can send at most queries to the machine.
Write a program which, given infomation of the bookshelf, specify the correct arrangement of the books by sending at most queries.
제한
- .
- ().
- ().
- Given values are all integers.
예제
이 문제는 공개된 예제가 없습니다.