結果

問題 No.1306 Exactly 2 Digits
ユーザー mkawa2mkawa2
提出日時 2020-12-04 12:58:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,610 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 25,580 KB
平均クエリ数 1372.42
最終ジャッジ日時 2023-09-24 08:59:19
合計ジャッジ時間 25,479 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 40 ms
24,576 KB
testcase_02 AC 40 ms
24,852 KB
testcase_03 WA -
testcase_04 AC 39 ms
24,872 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 40 ms
24,756 KB
testcase_08 AC 41 ms
24,184 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 39 ms
24,580 KB
testcase_13 AC 43 ms
24,228 KB
testcase_14 WA -
testcase_15 AC 41 ms
24,692 KB
testcase_16 WA -
testcase_17 AC 41 ms
24,792 KB
testcase_18 AC 40 ms
24,884 KB
testcase_19 AC 39 ms
24,676 KB
testcase_20 AC 40 ms
24,208 KB
testcase_21 AC 41 ms
24,220 KB
testcase_22 AC 41 ms
24,140 KB
testcase_23 RE -
testcase_24 AC 40 ms
24,472 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 44 ms
24,372 KB
testcase_29 RE -
testcase_30 AC 45 ms
24,612 KB
testcase_31 AC 45 ms
24,384 KB
testcase_32 AC 45 ms
24,028 KB
testcase_33 AC 48 ms
24,656 KB
testcase_34 AC 46 ms
24,328 KB
testcase_35 AC 46 ms
24,500 KB
testcase_36 AC 46 ms
24,132 KB
testcase_37 AC 46 ms
24,264 KB
testcase_38 RE -
testcase_39 AC 45 ms
24,332 KB
testcase_40 RE -
testcase_41 AC 40 ms
24,972 KB
testcase_42 AC 40 ms
24,492 KB
testcase_43 AC 42 ms
24,680 KB
testcase_44 AC 45 ms
24,792 KB
testcase_45 RE -
testcase_46 AC 46 ms
24,616 KB
testcase_47 AC 45 ms
24,452 KB
testcase_48 AC 44 ms
24,616 KB
testcase_49 RE -
testcase_50 AC 47 ms
24,156 KB
testcase_51 AC 53 ms
24,268 KB
testcase_52 AC 53 ms
24,300 KB
testcase_53 AC 54 ms
24,256 KB
testcase_54 RE -
testcase_55 AC 58 ms
24,912 KB
testcase_56 AC 66 ms
24,376 KB
testcase_57 AC 60 ms
24,772 KB
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 AC 72 ms
24,936 KB
testcase_62 RE -
testcase_63 AC 73 ms
25,004 KB
testcase_64 RE -
testcase_65 AC 92 ms
24,800 KB
testcase_66 AC 89 ms
24,848 KB
testcase_67 AC 97 ms
24,952 KB
testcase_68 AC 105 ms
24,632 KB
testcase_69 AC 96 ms
25,224 KB
testcase_70 RE -
testcase_71 AC 117 ms
24,624 KB
testcase_72 AC 117 ms
24,752 KB
testcase_73 AC 130 ms
24,624 KB
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 AC 150 ms
24,856 KB
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 AC 168 ms
25,216 KB
testcase_83 RE -
testcase_84 AC 165 ms
24,944 KB
testcase_85 RE -
testcase_86 RE -
testcase_87 AC 177 ms
25,364 KB
testcase_88 RE -
testcase_89 RE -
testcase_90 RE -
testcase_91 AC 145 ms
25,540 KB
testcase_92 AC 156 ms
25,056 KB
testcase_93 AC 171 ms
24,884 KB
testcase_94 AC 145 ms
25,172 KB
testcase_95 RE -
testcase_96 AC 168 ms
24,936 KB
testcase_97 AC 199 ms
25,364 KB
testcase_98 AC 156 ms
25,000 KB
testcase_99 RE -
testcase_100 RE -
testcase_101 RE -
testcase_102 RE -
testcase_103 AC 180 ms
25,444 KB
testcase_104 AC 163 ms
25,328 KB
testcase_105 AC 153 ms
25,268 KB
testcase_106 AC 155 ms
25,392 KB
testcase_107 AC 167 ms
25,208 KB
testcase_108 AC 181 ms
24,948 KB
testcase_109 AC 193 ms
24,960 KB
testcase_110 RE -
testcase_111 AC 182 ms
25,044 KB
testcase_112 AC 172 ms
24,864 KB
testcase_113 AC 168 ms
24,960 KB
testcase_114 RE -
testcase_115 AC 167 ms
25,580 KB
testcase_116 AC 177 ms
24,936 KB
testcase_117 AC 172 ms
24,936 KB
testcase_118 AC 177 ms
24,960 KB
testcase_119 RE -
testcase_120 AC 143 ms
24,940 KB
testcase_121 AC 154 ms
25,152 KB
testcase_122 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

# aa = [12, 13, 11, 6, 15, 5, 7, 9, 14, 10, 8, 4]
# aa = [8, 14, 7, 12, 13, 4, 15, 11, 5, 9, 6, 10]
# def ask(i, j):
#     a = aa[i]//n-aa[j]//n
#     b = aa[i]%n-aa[j]%n
#     return min(a, b), max(a, b)

def ask(i, j):
    print("?", i+1, j+1, flush=True)
    p, q = map(int, input().split())
    return p, q

n = int(input())
m = n**2-n
pqi = defaultdict(list)
for i in range(m-1):
    p, q = ask(i, m-1)
    pqi[p, q].append(i)
# print(pqi)

ans = [0]*m
(p0, q0), mni = min(pqi.items(), key=lambda x: sum(x[0]))
(p1, q1), mxi = max(pqi.items(), key=lambda x: sum(x[0]))
# print(p0, q0, mni)
# print(p1, q1, mxi)

if len(mxi) == 2:
    a = 1
    b = 0
    ans[mxi[0]] = n**2-1
elif len(mni) == 2:
    a = n-1
    b = n-1
    ans[mni[0]] = n
else:
    can = [(n-1-p1, n-1-q1), (n-1-q1, n-1-p1)]
    if (1-p0, -q0) in can:
        a, b = 1-p0, -q0
    else:
        a, b = 1-q0, -p0
    ans[mxi[0]] = n**2-1
    ans[mni[0]] = n

ans[-1] = a*n+b
# print(ans)

for (p, q), ii in pqi.items():
    if len(ii) == 1:
        i = ii[0]
        if ans[i]: continue
        x0, y0 = a+p, b+q
        x1, y1 = a+q, b+p
        if 1 <= x0 < n and 0 <= y0 < n:
            ans[i] = x0*n+y0
        else:
            ans[i] = x1*n+y1

(p2, q2), [ci] = max(pqi.items(), key=lambda x: x[0][1]-x[0][0])
# print(p2, q2, ci)

a, b = divmod(ans[ci], n)
for i in range(m):
    if ans[i]: continue
    p, q = ask(i, ci)
    x0, y0 = a+p, b+q
    x1, y1 = a+q, b+p
    if 1 <= x0 < n and 0 <= y0 < n:
        ans[i] = x0*n+y0
    else:
        ans[i] = x1*n+y1

print("!", end=" ")
print(*ans)
0