結果
問題 |
No.2496 LCM between Permutations
|
ユーザー |
![]() |
提出日時 | 2023-10-06 22:55:22 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,409 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 94,620 KB |
平均クエリ数 | 953.24 |
最終ジャッジ日時 | 2024-07-26 16:50:13 |
合計ジャッジ時間 | 6,110 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 17 RE * 11 |
ソースコード
from math import lcm, gcd def main(): N = int(input()) A = [-1 for _ in range(N)] B = [-1 for _ in range(N)] b_lcm_azero = [] for i in range(N): print("? 1 {}".format(i + 1), flush=True) x = int(input()) b_lcm_azero.append(x) a_0 = min(b_lcm_azero) A[0] = a_0 b_one_cand = [] for i in range(N): if b_lcm_azero[i] == a_0: b_one_cand.append(i) for i in range(1, N): values = [] for c in b_one_cand: print("? {} {}".format(i + 1, c + 1), flush=True) x = int(input()) values.append(x) b_one_cand_nxt = [] m = min(values) A[i] = m for j in range(len(b_one_cand)): if values[j] == m: b_one_cand_nxt.append(b_one_cand[j]) b_one_cand = b_one_cand_nxt if len(b_one_cand) == 1: break j = b_one_cand[0] B[j] = 1 for i in range(N): if A[i] != -1: continue print("? {} {}".format(i + 1, j + 1), flush=True) x = int(input()) A[i] = x j = -1 for i in range(N): if A[i] == 1: j = i for i in range(N): if B[i] != -1: continue print("? {} {}".format(j + 1, i + 1), flush=True) x = int(input()) B[i] = x print("!", *A, *B, flush=True) main()