結果
問題 | No.1306 Exactly 2 Digits |
ユーザー | shotoyoo |
提出日時 | 2020-12-03 12:27:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 307 ms / 2,000 ms |
コード長 | 3,413 bytes |
コンパイル時間 | 365 ms |
コンパイル使用メモリ | 82,204 KB |
実行使用メモリ | 96,164 KB |
平均クエリ数 | 1425.22 |
最終ジャッジ日時 | 2024-07-17 08:41:06 |
合計ジャッジ時間 | 26,949 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
71,052 KB |
testcase_01 | AC | 66 ms
72,972 KB |
testcase_02 | AC | 66 ms
71,928 KB |
testcase_03 | AC | 67 ms
74,188 KB |
testcase_04 | AC | 66 ms
73,328 KB |
testcase_05 | AC | 67 ms
73,688 KB |
testcase_06 | AC | 69 ms
74,088 KB |
testcase_07 | AC | 67 ms
73,544 KB |
testcase_08 | AC | 67 ms
73,132 KB |
testcase_09 | AC | 69 ms
73,144 KB |
testcase_10 | AC | 69 ms
73,456 KB |
testcase_11 | AC | 66 ms
74,604 KB |
testcase_12 | AC | 66 ms
74,556 KB |
testcase_13 | AC | 67 ms
74,004 KB |
testcase_14 | AC | 67 ms
72,936 KB |
testcase_15 | AC | 67 ms
73,304 KB |
testcase_16 | AC | 68 ms
74,036 KB |
testcase_17 | AC | 68 ms
72,888 KB |
testcase_18 | AC | 68 ms
73,224 KB |
testcase_19 | AC | 68 ms
73,068 KB |
testcase_20 | AC | 68 ms
74,624 KB |
testcase_21 | AC | 68 ms
73,140 KB |
testcase_22 | AC | 68 ms
74,200 KB |
testcase_23 | AC | 69 ms
74,568 KB |
testcase_24 | AC | 70 ms
74,304 KB |
testcase_25 | AC | 68 ms
73,448 KB |
testcase_26 | AC | 70 ms
74,916 KB |
testcase_27 | AC | 70 ms
73,832 KB |
testcase_28 | AC | 71 ms
73,892 KB |
testcase_29 | AC | 69 ms
74,680 KB |
testcase_30 | AC | 70 ms
73,164 KB |
testcase_31 | AC | 70 ms
73,656 KB |
testcase_32 | AC | 69 ms
74,344 KB |
testcase_33 | AC | 70 ms
74,012 KB |
testcase_34 | AC | 71 ms
73,628 KB |
testcase_35 | AC | 71 ms
73,808 KB |
testcase_36 | AC | 70 ms
73,164 KB |
testcase_37 | AC | 71 ms
73,432 KB |
testcase_38 | AC | 69 ms
73,608 KB |
testcase_39 | AC | 71 ms
73,296 KB |
testcase_40 | AC | 69 ms
73,540 KB |
testcase_41 | AC | 70 ms
73,268 KB |
testcase_42 | AC | 70 ms
73,612 KB |
testcase_43 | AC | 71 ms
74,404 KB |
testcase_44 | AC | 72 ms
73,868 KB |
testcase_45 | AC | 74 ms
74,840 KB |
testcase_46 | AC | 75 ms
74,752 KB |
testcase_47 | AC | 78 ms
79,076 KB |
testcase_48 | AC | 77 ms
74,108 KB |
testcase_49 | AC | 82 ms
79,900 KB |
testcase_50 | AC | 85 ms
79,976 KB |
testcase_51 | AC | 89 ms
81,932 KB |
testcase_52 | AC | 91 ms
81,968 KB |
testcase_53 | AC | 97 ms
82,644 KB |
testcase_54 | AC | 96 ms
84,440 KB |
testcase_55 | AC | 103 ms
85,088 KB |
testcase_56 | AC | 107 ms
86,812 KB |
testcase_57 | AC | 114 ms
87,516 KB |
testcase_58 | AC | 116 ms
88,392 KB |
testcase_59 | AC | 117 ms
90,984 KB |
testcase_60 | AC | 126 ms
89,192 KB |
testcase_61 | AC | 125 ms
87,760 KB |
testcase_62 | AC | 135 ms
90,460 KB |
testcase_63 | AC | 142 ms
90,628 KB |
testcase_64 | AC | 150 ms
94,520 KB |
testcase_65 | AC | 156 ms
94,028 KB |
testcase_66 | AC | 162 ms
94,456 KB |
testcase_67 | AC | 167 ms
94,444 KB |
testcase_68 | AC | 178 ms
94,452 KB |
testcase_69 | AC | 188 ms
95,136 KB |
testcase_70 | AC | 198 ms
95,040 KB |
testcase_71 | AC | 212 ms
95,756 KB |
testcase_72 | AC | 215 ms
96,072 KB |
testcase_73 | AC | 206 ms
96,116 KB |
testcase_74 | AC | 228 ms
96,164 KB |
testcase_75 | AC | 212 ms
95,160 KB |
testcase_76 | AC | 231 ms
95,020 KB |
testcase_77 | AC | 239 ms
94,604 KB |
testcase_78 | AC | 240 ms
94,700 KB |
testcase_79 | AC | 244 ms
94,692 KB |
testcase_80 | AC | 248 ms
94,628 KB |
testcase_81 | AC | 233 ms
95,000 KB |
testcase_82 | AC | 277 ms
95,844 KB |
testcase_83 | AC | 285 ms
95,360 KB |
testcase_84 | AC | 286 ms
94,772 KB |
testcase_85 | AC | 294 ms
95,624 KB |
testcase_86 | AC | 284 ms
95,524 KB |
testcase_87 | AC | 292 ms
95,284 KB |
testcase_88 | AC | 302 ms
95,596 KB |
testcase_89 | AC | 285 ms
95,668 KB |
testcase_90 | AC | 246 ms
95,116 KB |
testcase_91 | AC | 285 ms
95,840 KB |
testcase_92 | AC | 270 ms
95,048 KB |
testcase_93 | AC | 289 ms
95,256 KB |
testcase_94 | AC | 266 ms
95,552 KB |
testcase_95 | AC | 287 ms
95,504 KB |
testcase_96 | AC | 267 ms
95,752 KB |
testcase_97 | AC | 252 ms
95,556 KB |
testcase_98 | AC | 258 ms
95,020 KB |
testcase_99 | AC | 281 ms
95,736 KB |
testcase_100 | AC | 284 ms
95,688 KB |
testcase_101 | AC | 286 ms
95,692 KB |
testcase_102 | AC | 268 ms
95,620 KB |
testcase_103 | AC | 278 ms
95,520 KB |
testcase_104 | AC | 279 ms
95,540 KB |
testcase_105 | AC | 283 ms
95,628 KB |
testcase_106 | AC | 253 ms
95,276 KB |
testcase_107 | AC | 284 ms
95,872 KB |
testcase_108 | AC | 261 ms
95,228 KB |
testcase_109 | AC | 300 ms
95,668 KB |
testcase_110 | AC | 265 ms
95,620 KB |
testcase_111 | AC | 271 ms
95,868 KB |
testcase_112 | AC | 252 ms
95,048 KB |
testcase_113 | AC | 298 ms
95,504 KB |
testcase_114 | AC | 307 ms
95,644 KB |
testcase_115 | AC | 283 ms
95,408 KB |
testcase_116 | AC | 298 ms
95,408 KB |
testcase_117 | AC | 294 ms
95,292 KB |
testcase_118 | AC | 303 ms
95,608 KB |
testcase_119 | AC | 274 ms
95,564 KB |
testcase_120 | AC | 247 ms
95,268 KB |
testcase_121 | AC | 287 ms
95,172 KB |
testcase_122 | AC | 282 ms
95,672 KB |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") DEBUG = False def main(n,a): # print(a) N = 0 def _sub(i,j): p = a[i-1]//n - a[j-1]//n q = a[i-1]%n - a[j-1]%n if p>q: p,q = q,p return p,q import sys def query(i,j): nonlocal N N += 1 print("? {0} {1}".format(i, j)) sys.stdout.flush() if DEBUG: return _sub(i,j) else: return tuple(map(int, input().split())) if n==2: t = query(1,2) if t==(-1,0): print("! 2 3") else: print("! 3 2") return m = n*n-n ts = [query(1,i) for i in range(2,m+1)] from collections import defaultdict c = defaultdict(int) for t in ts: c[t[0]] += 1 c[t[1]] += 1 kv = list(c.items()) kv.sort() ys = [] if kv[0][1]==n-1: val = kv[0][0] y = kv[0][0] + n - 1 for item in kv: if item[1]==2*n-1 or (item[1]==2*n-3 and item[0]==0): break else: ys.append(item[0]) x = item[0] + n - 1 # print(x,item) else: # assert kv[-1][1]==n-1 y = kv[-1][0] val = kv[-1][0] for item in kv[::-1]: if item[1]==2*n-1 or (item[1]==2*n-3 and item[0]==0): break else: ys.append(item[0]) x = item[0] + 1 ans = [None]*m ans[0] = (x,y) xy2i = defaultdict(list) # print(val, ys, ts) for i,t in enumerate(ts): xy2i[min(t),max(t)].append(i) if val in t: if t[0]==val: t = (t[1], t[0]) ans[i+1] = (x-t[0], y-t[1]) if x-t[0]==n-1 and y-t[1]==0: index = i large = True elif x-t[0]==1 and y-t[1]==n-1: index = i large = False else: for vv in ys[1:]: if vv in t: if t[0]==vv: t = (t[1],t[0]) ans[i+1] = (x-t[0], y-t[1]) for i,t in enumerate(ts): if ans[i+1] is None: tt = query(index+2, i+2) if large: tt = (tt[1],tt[0]) ans[i+1] = (n-1-tt[0], -tt[1]) else: ans[i+1] = (1-tt[0], n-1-tt[1]) xx,yy = x - ans[i+1][0], y - ans[i+1][1] if xx<=yy: for ii in xy2i[xx,yy]: if i==ii: continue if ans[ii+1] is None: ans[ii+1] = (x-yy, y-xx) # print(ans[ii+1], ii+1) else: for ii in xy2i[yy,xx]: if i==ii: continue if ans[ii+1] is None: ans[ii+1] = (x-yy, y-xx) # print(ans[ii+1], ii+1) l = [item[0]*n+item[1] for item in ans] print("! "+ " ".join(map(str, l))) # print(xy2i) assert N<=3*n*(n-1)//2 # a = [3,5,4,8,7,6] from itertools import permutations from random import shuffle import random # random.seed(0) n = int(input()) l = list(range(n, n*n)) shuffle(l) main(n,l) # for a in permutations(range(n, n*n)): # main(n,list(a))