結果

問題 No.3237 Find the Treasure!
ユーザー sasa8uyauya
提出日時 2025-08-16 02:31:51
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 787 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 82,668 KB
実行使用メモリ 97,464 KB
平均クエリ数 3.96
最終ジャッジ日時 2025-08-16 02:32:02
合計ジャッジ時間 10,746 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other RE * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
e=[[] for i in range(n)]
es=[]
for i in range(n-1):
  u,v=map(int,input().split())
  u-=1
  v-=1
  e[u]+=[v]
  e[v]+=[u]
  es+=[(u,v)]
v=[0]*n
u=[0]*n
q=[0]
v[0]=1
for s in q:
  for t in e[s]:
    if v[t]==0:
      v[t]=1
      u[t]=u[s]^1
      q+=[t]
q=[a+1 if u[a] else b+1 for a,b in es]
print("?",*q)
a=input()
if a=="Yes":
  p=[i for i in range(n) if u[i]==1]
else:
  p=[i for i in range(n) if u[i]==0]
while len(p)>1:
  pl=p[:len(p)//2]
  pr=p[len(p)//2:]
  u=[0]*n
  for i in pl:
    u[i]=1
  for i in pr:
    u[i]=-1
  q=[]
  for a,b in es:
    if u[a]==1:
      q+=[a+1]
    elif u[a]==-1:
      q+=[b+1]
    elif u[b]==1:
      q+=[b+1]
    elif u[b]==-1:
      q+=[a+1]
  print("?",*q)
  a=input()
  if a=="Yes":
    p=pl
  else:
    p=pr
a=p[0]+1
print("!",a)
0