結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-19 18:32:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 639 bytes |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 79,344 KB |
| 平均クエリ数 | 200.11 |
| 最終ジャッジ日時 | 2024-07-17 07:12:36 |
| 合計ジャッジ時間 | 7,332 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 27 |
ソースコード
import sys
def query(x,y):
print("?",x,y)
sys.stdout.flush()
return int(input())
from collections import deque
N = int(input())
deq = deque([i for i in range(1,N+1)])
win = [[] for i in range(N+1)]
while len(deq)>1:
ndeq = deque([])
while deq:
x = deq.popleft()
if not deq:
ndeq.append(x)
break
y = deq.popleft()
z = query(x,y)
if z==x:
win[x].append(y)
else:
win[y].append(x)
ndeq.append(z)
deq = ndeq
one = deq[0]
L = win[one]
res = L[0]
for i in range(1,len(L)):
res = query(res,L[i])
print(res)