시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 57 | 19 | 17 | 34.694% |
In JOI Zoo, there are 2N chameleons, numbered from 1 to 2N. Among them, N chameleons have sex X. The remaining N chameleons have sex Y.
Each chameleon has its original color. The following are known about the original colors.
Now, JOI Zoo is in the season of new loves.
You can gather some of the chameleons and organize a meeting. For each chameleon s attending the meeting, let t be the chameleon which s loves. The skin color of s is decided as follows.
The skin color of a chameleon may change for different meetings. For each meeting you organize, you can count the number of kinds of skin colors of the chameleons attending the meeting.
By organizing meetings at most 20 000 times, you want to determine all pairs of chameleons with the same original color.
Write a program which, given the number of chameleons, determines all pairs of chameleons with the same original color by organizing meetings at most 20 000 times.
You need to submit one file.
The name of the file you submit is chameleon.cpp. It should implement the following function. The program should include chameleon.h.
void Solve(int N)
Your program can call the following function.
int Query(const std::vector &p)
p
is the list of chameleons attending the meeting.p
should be an integer greater between 1 and 2N, inclusive. If this condition is not satisfied, your program is judged as Wrong Answer [1].p
should be distinct. If this condition is not satisfied, your program is judged as Wrong Answer [2].void Answer(int a, int b)
a
and b
mean the chameleon a and the chameleon b have the same original color.Answer
exactly N times. When the function Solve terminates, if the number of calls to the function Answer is different from N, your program is judged as Wrong Answer [7].Yi (1 ≤ i ≤ 2N) is the sex of the chameleon i, which is 0 or 1. It is 0 if the sex is X, and 1 if the sex is Y.
Ci (1 ≤ i ≤ 2N) is the original color of the chameleon i, which is an integer greater than or equal to 1 and less than or equal to N.
Li (1 ≤ i ≤ 2N) is the number of the chameleon which the chameleon i loves.
번호 | 배점 | 제한 |
---|---|---|
1 | 4 | LLi = i (1 ≤ i ≤ 2N). |
2 | 20 | N ≤ 7. |
3 | 20 | N ≤ 50. |
4 | 20 | Yi = 0 (1 ≤ i ≤ N). |
5 | 36 | No additional constraints. |
Here is a sample input for the sample grader and corresponding function calls.
Sample Input 1 | Sample Calls | ||
---|---|---|---|
Call | Call | Return | |
4 1 0 1 0 0 1 1 0 4 4 1 2 1 2 3 3 4 3 8 7 6 5 2 1 |
Solve(4) |
||
Query([]) |
0 |
||
Query([6, 2]) |
2 |
||
Query([8, 1, 6]) |
2 |
||
Query([7, 1, 3, 5, 6, 8]) |
4 |
||
Query([8, 6, 4, 1, 5]) |
3 |
||
Answer(6, 4) |
|||
Answer(7, 8) |
|||
Answer(2, 1) |
|||
Answer(3, 5) |
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)