Treasure
시간 제한3초메모리 제한1024 MB
서로 다른 정수 좌표 점 N개의 위치를 종이에 적되 종이가 섞여도 복원할 수 있어야 하며, 종이 수를 최소화하는 방법을 설계한다.
문제
A long time ago, Horus and Seth fought over who would succeed Osiris as King. Their contention was judged by Raa, who gave them a series of challenges to determine who is more worthy of the throne. Horus managed to win all of the challenges, but Raa is still not sure if Horus is qualified to rule over Egypt because of his young age. So Raa decided to give Horus one final challenge to prove his strength and settle this fight once and for all.
The final challenge for Horus is to collect treasure chests numbered from to spread all over Egypt. The locations of the chests are given to Horus as points in the -dimensional plane and are pairwise distinct. Specifically, the location of chest () is a point , where both and are integers between and , inclusive.
Horus is going to record the locations of the chests by taking notes in his papyrus notebook. Each sheet of this notebook can store a single non-negative integer not greater than . Sadly, Seth is going to shuffle the notebook sheets after Horus takes all the notes in his notebook.
Your task is to help Horus by implementing two procedures that would:
- record the locations of the chests by writing numbers on the notebook sheets,
- recover the locations of the chests, given the notebook sheets in an arbitrary order.
Note that your score in this task depends on the number of sheets used, that is, the number of numbers written in the notebook.
제한
- ()
- ()
- No two chests have the same location.
- The total number of chests in all scenarios does not exceed .
- Array is a permutation of .
예제
이 문제는 공개된 예제가 없습니다.