結果

問題 No.1306 Exactly 2 Digits
ユーザー mkawa2mkawa2
提出日時 2020-12-04 00:59:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,745 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 11,168 KB
実行使用メモリ 26,380 KB
平均クエリ数 1245.39
最終ジャッジ日時 2023-09-24 08:52:16
合計ジャッジ時間 19,906 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
24,392 KB
testcase_01 AC 44 ms
24,432 KB
testcase_02 AC 43 ms
24,888 KB
testcase_03 AC 44 ms
24,528 KB
testcase_04 AC 45 ms
24,868 KB
testcase_05 AC 44 ms
24,436 KB
testcase_06 AC 44 ms
25,068 KB
testcase_07 AC 45 ms
24,540 KB
testcase_08 AC 45 ms
24,736 KB
testcase_09 AC 45 ms
24,952 KB
testcase_10 AC 44 ms
24,628 KB
testcase_11 AC 43 ms
24,700 KB
testcase_12 AC 43 ms
24,828 KB
testcase_13 WA -
testcase_14 AC 45 ms
24,424 KB
testcase_15 AC 45 ms
24,908 KB
testcase_16 AC 44 ms
24,556 KB
testcase_17 AC 44 ms
24,464 KB
testcase_18 AC 44 ms
24,616 KB
testcase_19 AC 44 ms
24,776 KB
testcase_20 AC 44 ms
24,444 KB
testcase_21 AC 45 ms
25,068 KB
testcase_22 AC 44 ms
24,660 KB
testcase_23 WA -
testcase_24 AC 46 ms
24,264 KB
testcase_25 WA -
testcase_26 AC 46 ms
24,456 KB
testcase_27 WA -
testcase_28 AC 45 ms
24,704 KB
testcase_29 AC 44 ms
24,588 KB
testcase_30 AC 45 ms
24,876 KB
testcase_31 AC 44 ms
24,460 KB
testcase_32 AC 45 ms
24,408 KB
testcase_33 AC 45 ms
25,100 KB
testcase_34 AC 45 ms
24,492 KB
testcase_35 AC 46 ms
24,276 KB
testcase_36 AC 46 ms
24,936 KB
testcase_37 AC 46 ms
24,616 KB
testcase_38 AC 46 ms
24,496 KB
testcase_39 AC 45 ms
24,860 KB
testcase_40 AC 46 ms
24,480 KB
testcase_41 AC 45 ms
24,588 KB
testcase_42 AC 45 ms
24,632 KB
testcase_43 AC 46 ms
24,616 KB
testcase_44 AC 46 ms
24,632 KB
testcase_45 AC 49 ms
25,020 KB
testcase_46 AC 50 ms
24,752 KB
testcase_47 AC 50 ms
24,940 KB
testcase_48 AC 50 ms
24,692 KB
testcase_49 AC 54 ms
24,508 KB
testcase_50 AC 53 ms
25,076 KB
testcase_51 AC 56 ms
24,332 KB
testcase_52 AC 55 ms
24,940 KB
testcase_53 AC 57 ms
24,780 KB
testcase_54 AC 64 ms
24,696 KB
testcase_55 AC 61 ms
25,032 KB
testcase_56 AC 64 ms
25,228 KB
testcase_57 AC 65 ms
24,868 KB
testcase_58 WA -
testcase_59 AC 77 ms
24,736 KB
testcase_60 AC 80 ms
25,060 KB
testcase_61 AC 77 ms
24,720 KB
testcase_62 AC 84 ms
24,780 KB
testcase_63 AC 79 ms
24,760 KB
testcase_64 AC 92 ms
24,904 KB
testcase_65 AC 90 ms
24,892 KB
testcase_66 AC 90 ms
25,476 KB
testcase_67 AC 95 ms
24,948 KB
testcase_68 AC 102 ms
25,548 KB
testcase_69 AC 99 ms
25,172 KB
testcase_70 AC 118 ms
25,244 KB
testcase_71 AC 111 ms
25,216 KB
testcase_72 AC 116 ms
25,508 KB
testcase_73 AC 124 ms
25,760 KB
testcase_74 AC 130 ms
25,304 KB
testcase_75 AC 142 ms
25,684 KB
testcase_76 AC 152 ms
25,500 KB
testcase_77 AC 143 ms
25,452 KB
testcase_78 AC 141 ms
25,684 KB
testcase_79 AC 157 ms
25,452 KB
testcase_80 AC 158 ms
26,020 KB
testcase_81 AC 174 ms
25,948 KB
testcase_82 AC 157 ms
25,908 KB
testcase_83 AC 181 ms
25,608 KB
testcase_84 AC 166 ms
26,036 KB
testcase_85 AC 214 ms
25,728 KB
testcase_86 AC 199 ms
26,232 KB
testcase_87 AC 174 ms
26,380 KB
testcase_88 AC 205 ms
26,060 KB
testcase_89 AC 197 ms
25,628 KB
testcase_90 AC 201 ms
26,180 KB
testcase_91 AC 151 ms
25,796 KB
testcase_92 AC 162 ms
25,816 KB
testcase_93 AC 166 ms
25,976 KB
testcase_94 AC 152 ms
25,812 KB
testcase_95 AC 190 ms
25,816 KB
testcase_96 AC 161 ms
26,156 KB
testcase_97 AC 184 ms
26,124 KB
testcase_98 AC 156 ms
25,508 KB
testcase_99 AC 187 ms
26,084 KB
testcase_100 AC 172 ms
26,188 KB
testcase_101 AC 180 ms
25,564 KB
testcase_102 AC 186 ms
25,652 KB
testcase_103 AC 172 ms
25,920 KB
testcase_104 AC 166 ms
25,732 KB
testcase_105 AC 166 ms
25,744 KB
testcase_106 AC 160 ms
25,940 KB
testcase_107 AC 170 ms
26,168 KB
testcase_108 AC 180 ms
26,060 KB
testcase_109 AC 183 ms
25,744 KB
testcase_110 AC 194 ms
26,072 KB
testcase_111 AC 177 ms
26,072 KB
testcase_112 AC 170 ms
26,212 KB
testcase_113 AC 174 ms
25,704 KB
testcase_114 AC 195 ms
26,252 KB
testcase_115 AC 166 ms
25,416 KB
testcase_116 AC 177 ms
25,908 KB
testcase_117 AC 172 ms
26,104 KB
testcase_118 AC 174 ms
26,084 KB
testcase_119 AC 204 ms
26,104 KB
testcase_120 AC 155 ms
25,868 KB
testcase_121 AC 159 ms
25,616 KB
testcase_122 AC 200 ms
25,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

# aa = [12, 13, 11, 6, 15, 5, 7, 9, 14, 10, 8, 4]
# aa = [6, 4, 8, 7, 5, 3]
# 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)

memo={}
def ask(i,j):
    if (i,j) in memo:return memo[i,j]
    print("?",i+1,j+1,flush=True)
    p,q=map(int,input().split())
    memo[i,j]=(p,q)
    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 (p0, q0) == (0, 1):
    a = 1
    b = 0
    j, c, d = mxi[0], n-1, n-1
    ans[mxi[0]] = n**2-1
elif (p1, q1) == (-1, 0):
    a = n-1
    b = n-1
    j, c, d = mni[0], 1, 0
    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
    j, c, d = mxi[0], n-1, n-1
    ans[mxi[0]] = n**2-1
    ans[mni[0]] = n
# print("abcd", a, b, c, d, j)

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
    else:
        i0, i1 = ii
        pj, qj = ask(i0, j)
        can = [(c+pj, d+qj), (c+qj, d+pj)]
        if (a+p, b+q) in can:
            ans[i0] = (a+p)*n+(b+q)
            ans[i1] = (a+q)*n+(b+p)
        else:
            ans[i1] = (a+p)*n+(b+q)
            ans[i0] = (a+q)*n+(b+p)

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