結果
問題 | No.1306 Exactly 2 Digits |
ユーザー |
![]() |
提出日時 | 2024-01-01 21:43:57 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,598 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 29,152 KB |
平均クエリ数 | 1018.09 |
最終ジャッジ日時 | 2024-09-27 17:32:31 |
合計ジャッジ時間 | 34,419 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 123 |
ソースコード
from collections import defaultdict N=int(input()) i=0 dct=defaultdict(list) PQ=[] s=0 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)) s+=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): s+=x+y s//=N*N for x in range(1,N): for y in range(N): if x+y!=s: continue 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)