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

30953번 - Interactive Reconstruction 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 (추가 시간 없음) 1024 MB35262575.758%

문제

This is an interactive task where your program will communicate with a grader through standard input and output. Your task is to reconstruct a labelled tree with $N$ nodes and $N-1$ edges. Nodes are labelled from 1ドル$ to $N$.

Your program is allowed to make a few queries of the following type: Your program should print a string of $N$ characters, consisting only of zeros and ones, one corresponding to each node. The grader will return a sequence of $N$ space-separated integers, the $i$-th representing the sum of the values (i.e. digits of the query string) of all neighbours of the $i$-th node. That is, if node $j$ is a neighbour of node $i,ドル then the $j$-th digit of the query string counts towards the sum in the $i$-th number of the grader's answer.

See the example below for an illustration.

입력과 출력

The first input line will contain the number $N,ドル the number of nodes in the tree.

Your program then has two options:

  1. Print "QUERY" (without quotation marks), a space, and a string of $N$ zeros and ones.
  2. Print "ANSWER" (without quotation marks), a newline, and $N - 1$ lines, each containing a pair of space-separated integers $a, b,ドル indicating that there exists an edge between nodes $a$ and $b$.

If your program prints a query, this will be followed by the grader returning a line with $N$ space-separated integers, one per node. If your program prints an answer, the grader will check the returned tree for correctness.

If there was a mistake in your queries, either due to incorrect formatting or due to an exceeded number of queries, the grader will immediately terminate.

Important: Ensure that your program flushes its output after printing and correctly exits after printing the answer.

입력

출력

제한

  • 2ドル \leq N \leq 3\cdot 10^4$
  • At most 2ドル \uparrow \uparrow 3 = 2^{(2^2)} = 16$ queries are allowed. The final answer does not count toward this restriction.

예제 입력 1

5
0 0 1 2 0
1 1 0 0 1
0 0 0 1 0

예제 출력 1

QUERY 10001
QUERY 00010
QUERY 10000
ANSWER
1 4
4 2
5 4
3 5

힌트

The tree in question is the following one:

1-4-2
 |
 5-3

With the three queries in the example, it is possible to reconstruct it uniquely.

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2023 I번

채점 및 기타 정보

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

출처

대학교 대회

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

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