結果
| 問題 | No.850 企業コンテスト2位 | 
| コンテスト | |
| ユーザー | 👑  SPD_9X2 | 
| 提出日時 | 2025-10-05 05:11:15 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 89 ms / 2,000 ms | 
| コード長 | 666 bytes | 
| コンパイル時間 | 460 ms | 
| コンパイル使用メモリ | 82,524 KB | 
| 実行使用メモリ | 80,356 KB | 
| 平均クエリ数 | 200.07 | 
| 最終ジャッジ日時 | 2025-10-05 05:11:22 | 
| 合計ジャッジ時間 | 5,323 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 27 | 
ソースコード
"""
https://yukicoder.me/problems/no/850
トーナメントをすると、2位は1位に負けた中にいる
"""
from collections import deque
N = int(input())
beat = {}
q = deque( [i+1 for i in range(N)] )
while len(q) >= 2:
    a = q.popleft()
    b = q.popleft()
    print ("?",a,b,flush=True)
    win = int(input())
    lose = a+b-win
    q.append(win)
    beat[lose] = win
first = q.popleft()
for v in beat:
    if beat[v] == first:
        q.append(v)
while len(q) >= 2:
    a = q.popleft()
    b = q.popleft()
    print ("?",a,b,flush=True)
    win = int(input())
    lose = a+b-win
    q.append(win)
print ("!",q.popleft(),flush=True)
            
            
            
        