結果

問題 No.2496 LCM between Permutations
コンテスト
ユーザー rlangevin
提出日時 2023-10-06 23:19:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 784 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 167 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 103,556 KB
平均クエリ数 928.31
最終ジャッジ日時 2026-04-03 17:42:09
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 RE * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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