Treasure

시간 제한3초메모리 제한1024 MB

요약
서로 다른 정수 좌표 점 N개의 위치를 종이에 적되 종이가 섞여도 복원할 수 있어야 하며, 종이 수를 최소화하는 방법을 설계한다.
난이도

어려움10점 중 9점

유형
수학, 조합론, 정렬, 구현
정답자
아직 제출이 없습니다

문제

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 NN treasure chests numbered from 00 to N−1N - 1 spread all over Egypt. The locations of the chests are given to Horus as points in the 22-dimensional plane and are pairwise distinct. Specifically, the location of chest ii (0≤i<N0 ≤ i < N) is a point (X\[i],Y\[i])(X\[i], Y \[i]), where both X\[i]X\[i] and Y\[i]Y \[i] are integers between 00 and 5⋅1085 \cdot 10^8, 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 2⋅1092 \cdot 10^9. 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.

제한

  • 1≤T≤1001 ≤ T ≤ 100
  • 1≤N≤40,0001 ≤ N ≤ 40\\, 000
  • 0≤X\[i]≤5⋅1080 ≤ X\[i] ≤ 5 \cdot 10^8 (0≤i<N0 ≤ i < N)
  • 0≤Y\[i]≤5⋅1080 ≤ Y \[i] ≤ 5 \cdot 10^8 (0≤i<N0 ≤ i < N)
  • No two chests have the same location.
  • The total number of chests in all scenarios does not exceed 2⋅1052 \cdot 10^5.
  • Array SS is a permutation of EE.

예제

이 문제는 공개된 예제가 없습니다.