Logo
(追記) (追記ここまで)

28363번 - Island Alliances 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB55222038.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:

  • One line with three integers $n,ドル $m,ドル and $q,ドル the number of islands, the number of distrusting pairs of islands, and the number of proposals.
  • $m$ lines, the $i$th of which contains two integers $u_i$ and $v_i,ドル where 1ドル \leq u_i,v_i \leq n,ドル $u_i \neq v_i,ドル meaning that the inhabitants of islands $u_i$ and $v_i$ distrust each other. Each pair $(u_i, v_i)$ will be listed at most once.
  • $q$ lines, the $i$th of which contains two integers $a_i$ and $b_i,ドル where 1ドル \leq a_i,b_i \leq n,ドル describing the $i$th proposal. It is guaranteed that no proposal will ever call for a state to merge with itself, meaning that at the time when you receive the $i$th proposal, $a_i$ and $b_i$ are guaranteed to belong to different states.

출력

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.

제한

서브태스크

번호배점제한
115

2ドル \leq N \leq 500,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5$

217

2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 250,ドル 1ドル \leq Q \leq 10^5$

320

2ドル \leq N \leq 5,000円,ドル 1ドル \leq M \leq 5,000円,ドル 1ドル \leq Q \leq 10^5$

423

2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5,ドル maximum of one "REFUSE"

525

2ドル \leq N \leq 10^5,ドル 1ドル \leq M \leq 10^5,ドル 1ドル \leq Q \leq 10^5$

예제 입력 1

3 1 2
1 2
2 1
1 3

예제 출력 1

REFUSE
APPROVE

예제 입력 2

8 3 7
1 2
2 3
3 4
1 2
4 5
5 6
7 8
3 4
1 3
2 4

예제 출력 2

REFUSE
APPROVE
APPROVE
APPROVE
REFUSE
APPROVE
APPROVE

힌트

출처

Olympiad > Nordic Olympiad in Informatics > NOI 2023 B번

  • 문제를 만든 사람: Mårten Wiman

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /