結果

問題 No.3237 Find the Treasure!
コンテスト
ユーザー ああ
提出日時 2026-05-20 20:40:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,050 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 194 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 104,368 KB
平均クエリ数 13.74
最終ジャッジ日時 2026-05-20 20:40:29
合計ジャッジ時間 7,093 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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())
0