Anti-Closed Subsequences
시간 제한1초메모리 제한1024 MB
서로 다른 n개의 정수를 60개 이하의 무리로 나누되 어느 무리에서도 x+y=z인 세 원소가 나타나지 않도록 하고, 각 위치의 무리 번호를 출력한다.
문제
We consider a set of integers to be anti-closed if there do not exist elements , and in where (, and do not necessarily have to be distinct).
For example:
- is anti-closed, because no such , , exist
- is not anti-closed, because , , and are all in the set and
- is also not anti-closed, because and are in the set and
You are given an array of distinct integers. Partition it into at most anti-closed subsequences. Formally, find an array of size such that
- for all
- For each , the subsequence of containing all values at indices where is anti-closed (The empty subsequence is considered anti-closed)
It can be shown that a solution always exists.
입력
The first line of the input contains a single integer () --- the size of the array .
The next line of the input contains distinct integers () --- the elements of the array .
출력
Output integers (), representing the partition of , as described above.
If there are multiple solutions, print any.
힌트
For the first test case, the input array is partitioned into these subsequences:
- :
- :
- :
- :
We can show that each of these sets is anti-closed.