結果

問題 No.2496 LCM between Permutations
ユーザー rlangevin
提出日時 2023-10-06 23:19:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 784 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 96,084 KB
平均クエリ数 928.31
最終ジャッジ日時 2024-07-26 17:03:44
合計ジャッジ時間 6,151 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 RE * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import *
from math import *

N = int(input())
S = list(range(N))
now = 1
ansA = [0] * N
ansB = [0] * N
while S:
    temp = [0] * N
    g = -1
    newS = []
    for i in S:
        print("? {} {}".format(now, i + 1))
        sys.stdout.flush()
        temp[i] = int(input())
        if g == -1:
            g = temp[i]
        else:
            g = gcd(g, temp[i])
    C = Counter(temp)
    for i in range(N):
        if C[temp[i]] == 1:
            ansB[i] = temp[i] // g
        else:
            if temp[i]:
                newS.append(i)
    newS, S = S, newS
                
ind = ansB.index(1) + 1
for i in range(N):
    print("? {} {}".format(i + 1, ind))
    sys.stdout.flush()
    ansA[i] = int(input())
    
ans = ["!"] + ansA + ansB
print(*ans) 
0