結果
問題 |
No.1306 Exactly 2 Digits
|
ユーザー |
![]() |
提出日時 | 2024-01-01 21:32:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,476 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 82,364 KB |
実行使用メモリ | 109,236 KB |
平均クエリ数 | 444.40 |
最終ジャッジ日時 | 2024-09-27 17:31:56 |
合計ジャッジ時間 | 43,539 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 87 TLE * 4 -- * 32 |
ソースコード
from collections import defaultdict N=int(input()) i=0 dct=defaultdict(list) PQ=[] for j in range(1,N**2-N): print("?",i+1,j+1) p,q=map(int,input().split()) dct[(p,q)].append(j) PQ.append((p,q)) PQ.sort() X,Y=[None]*(N*N-N),[None]*(N*N-N) for x in range(1,N): for y in range(N): lst=[] for xx in range(1,N): for yy in range(N): if x==xx and y==yy: continue p,q=x-xx,y-yy if p>q: p,q=q,p lst.append((p,q)) lst.sort() if lst==PQ: X[i]=x Y[i]=y break else: continue break else: assert False for (p,q),lst in dct.items(): if len(lst)==1: j=lst[0] for xx,yy in ((x-p,y-q),(x-q,y-p)): if 1<=xx<N and 0<=yy<N: X[j]=xx Y[j]=yy for ii in range(N*N-N): if X[ii]!=None and X[ii]-Y[ii]!=X[i]-Y[i]: i=ii break else: assert False for (p,q),lst in dct.items(): if len(lst)==2: j=lst[0] print("?",i+1,j+1) pp,qq=map(int,input().split()) for xx,yy in ((x-p,y-q),(x-q,y-p)): if sorted([X[i]-xx,Y[i]-yy])==[pp,qq]: X[j]=xx Y[j]=yy break else: assert False jj=lst[1] X[jj]=2*x-p-q-xx Y[jj]=2*y-p-q-yy A=[x*N+y for x,y in zip(X,Y)] print("!",*A)