結果
| 問題 | No.3237 Find the Treasure! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-20 20:38:33 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,047 bytes |
| 記録 | |
| コンパイル時間 | 215 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 104,600 KB |
| 平均クエリ数 | 13.74 |
| 最終ジャッジ日時 | 2026-05-20 20:38:44 |
| 合計ジャッジ時間 | 8,886 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 22 |
ソースコード
from collections import deque
n=int(input())
v=[[] for i in range(n+1)]
x=[]
for i in range(n-1):
a,b=map(int,input().split());x.append((a,b))
v[a].append(b);v[b].append(a)
c=[0]*(n+1)
f=deque([(1,0,0,1)])
while f:
q,w,e,r=f.pop()
c[q]=r
if len(v[q])>e:
f.append((q,w,e+1,r))
if v[q][e]!=w:
f.append((v[q][e],q,0,r^1))
a=[]
for i,j in x:
if c[i]:
a.append(i)
else:
a.append(j)
print("?"," ".join(map(str,a)))
s=1 if input()=="Yes" else 0
a=set()
for i in range(1,n+1):
if c[i]==s:
a.add(i)
for i in range(14):
if len(a)==1:
break
b=set(list(a)[:len(a)//2])
k=[]
for j,l in x:
if j in b:
k.append(j)
elif l in b:
k.append(l)
else:
k.append(j)
print("?"," ".join(map(str,k)))
s=1 if input()=="Yes" else 0
if s:
a=b
else:
c=set()
for j in list(a):
if j in b:
continue
c.add(j)
a=c
print(a.pop())