結果
| 問題 |
No.3237 Find the Treasure!
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-08-30 01:46:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,076 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 82,516 KB |
| 実行使用メモリ | 97,828 KB |
| 平均クエリ数 | 13.52 |
| 最終ジャッジ日時 | 2025-08-30 01:47:01 |
| 合計ジャッジ時間 | 13,280 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 4 WA * 18 |
ソースコード
import sys
input = sys.stdin.readline
N=int(input())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
E=[[] for i in range(N+1)]
for x,y in EDGE:
E[x].append(y)
E[y].append(x)
X=[-1]*(N+1)
X[1]=0
Q=[1]
while Q:
x=Q.pop()
for to in E[x]:
if X[to]==-1:
X[to]=X[x]^1
Q.append(to)
LIST=[]
for i in range(1,N+1):
if X[i]==0:
LIST.append(i)
SET=set(LIST)
Q=[]
for i in range(N-1):
x,y=EDGE[i]
if x in SET:
Q.append(x)
else:
Q.append(y)
print("?",*Q,flush=True)
ret=input().strip()
if ret=="Yes":
pass
else:
LIST=[]
for i in range(1,N+1):
if X[i]==1:
LIST.append(i)
while len(LIST)>1:
LIST2=LIST[:len(LIST)//2]
SET=set(LIST2)
Q=[]
for i in range(N-1):
x,y=EDGE[i]
if x in SET:
Q.append(x)
else:
Q.append(y)
print("?",*Q,flush=True)
ret=input().strip()
if ret=="Yes":
LIST=LIST2
else:
LIST=LIST[len(LIST)//2:]
print("!",LIST[0],flush=True)
titia