| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 1024 MB | 55 | 22 | 20 | 38.462% |
In a vast ocean there are $n$ islands numbered from 1ドル$ to $n,ドル where each island constitutes a sovereign state.
However, the large number of states is making foreign policy a very complicated matter, so the inhabitants of the islands have decided to simplify things by joining into larger (but fewer) states. This endeavour has turned out to be easier said than done, because there are $m$ pairs of islands whose inhabitants distrust each other and refuse to be part of the same state.
The islanders have sent you $q$ proposals that you should process in order. The $i$th proposal calls for the state containing island $a_i$ to merge with the state containing island $b_i$. If the two states contain a pair of islands whose inhabitants distrust each other the proposal should be rejected, but otherwise the proposal should be approved and all the islands in the two states will henceforth be part of the same state.
Please help the islanders figure out which proposals should be rejected and which should be approved!
The input consists of:
Output $q$ lines, where the $i$th line should be "REFUSE" if the $i$th proposal should be refused, or "APPROVE" if the $i$th proposal should be approved.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 15 | 2ドル \leq N \leq 500,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5$ |
| 2 | 17 | 2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 250,ドル 1ドル \leq Q \leq 10^5$ |
| 3 | 20 | 2ドル \leq N \leq 5,000円,ドル 1ドル \leq M \leq 5,000円,ドル 1ドル \leq Q \leq 10^5$ |
| 4 | 23 | 2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5,ドル maximum of one " |
| 5 | 25 | 2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5$ |
3 1 2 1 2 2 1 1 3
REFUSE APPROVE
8 3 7 1 2 2 3 3 4 1 2 4 5 5 6 7 8 3 4 1 3 2 4
REFUSE APPROVE APPROVE APPROVE REFUSE APPROVE APPROVE
Olympiad > Nordic Olympiad in Informatics > NOI 2023 B번