結果
問題 |
No.850 企業コンテスト2位
|
ユーザー |
![]() |
提出日時 | 2020-03-31 12:12:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,703 bytes |
コンパイル時間 | 90 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 27,992 KB |
平均クエリ数 | 197.50 |
最終ジャッジ日時 | 2024-07-17 03:23:01 |
合計ジャッジ時間 | 5,759 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 WA * 24 |
ソースコード
#!/usr/bin/ python3.8 import sys readline = sys.stdin.readline # DEBUG = True DEBUG = False N = int(readline()) class Interactive: def __init__(self): self.ques_cnt = 0 self.create_data() def create_data(self): import numpy as np rank = np.arange(N + 1) np.random.shuffle(rank[1:]) self.rank = rank print('created', rank) def resp_ques(self, *args): x, y = args ret = x if self.rank[x] < self.rank[y] else y return str(ret) + '\n' def resp_ans(self, *args): x = args if self.rank[x] == 2: print('AC') else: print('WA') if DEBUG: interactive = Interactive() def question(*args, offset='?'): if offset is None: print(*args, flush=True) else: print(offset, *args, flush=True) if DEBUG: resp = interactive.resp_ques(*args) print(resp, end='') return resp else: return readline() def answer(*args, offset='!'): if offset is None: print(*args, flush=True) else: print(offset, *args, flush=True) if DEBUG: interactive.resp_ans(*args) else: exit() log = [] A = list(range(1, N + 1)) while len(A) >= 2: B = [] it = iter(A) for x, y in zip(it, it): ret = int(question(x, y)) log.append((x, y, ret)) B.append(ret) A = B best_x = A[0] A = [] for x, y, z in log: if z == best_x: A.append(x + y - z) while len(A) >= 2: B = [] it = iter(A) for x, y in zip(it, it): ret = int(question(x, y)) log.append((x, y, ret)) B.append(ret) A = B answer(A[0])