結果
| 問題 |
No.850 企業コンテスト2位
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2019-07-12 16:58:16 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 1,250 bytes |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 27,848 KB |
| 平均クエリ数 | 200.11 |
| 最終ジャッジ日時 | 2024-07-16 17:48:01 |
| 合計ジャッジ時間 | 3,603 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
N=int(input())
TOURNAMENT=[list(range(1,N+1))]
WINLIST=[]
while len(TOURNAMENT[-1])!=1:
LEN=len(TOURNAMENT[-1])
NEXT=[]
for i in range(0,LEN,2):
if i==LEN-1:
NEXT.append(TOURNAMENT[-1][i])
break
x=TOURNAMENT[-1][i]
y=TOURNAMENT[-1][i+1]
print("?",x,y,flush=True)
win=int(input())
if x==win:
NEXT.append(x)
WINLIST.append([x,y])
else:
NEXT.append(y)
WINLIST.append([y,x])
TOURNAMENT.extend([NEXT])
WIN1=TOURNAMENT[-1][-1]
TOURNAMENT2=[]
for x,y in WINLIST:
if x==WIN1:
TOURNAMENT2.append(y)
TOURNAMENT=[TOURNAMENT2]
while len(TOURNAMENT[-1])!=1:
LEN=len(TOURNAMENT[-1])
NEXT=[]
for i in range(0,LEN,2):
if i==LEN-1:
NEXT.append(TOURNAMENT[-1][i])
break
x=TOURNAMENT[-1][i]
y=TOURNAMENT[-1][i+1]
print("?",x,y,flush=True)
win=int(input())
if x==win:
NEXT.append(x)
WINLIST.append([x,y])
else:
NEXT.append(y)
WINLIST.append([y,x])
TOURNAMENT.extend([NEXT])
print("!",TOURNAMENT[-1][-1],flush=True)
titia