結果
問題 |
No.1896 Arrays and XOR Procedure 2
|
ユーザー |
![]() |
提出日時 | 2021-12-21 19:10:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 838 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 79,156 KB |
最終ジャッジ日時 | 2024-09-16 08:33:19 |
合計ジャッジ時間 | 7,354 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 12 WA * 15 |
ソースコード
import heapq n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) b_min=sorted(a+b)[n] operation=[] idx=-1 for i in range(n): if b[i]==b_min: idx=i if idx==-1: idx2=-1 for i in range(n): if a[i]==b_min: idx2=i operation.append((2,idx2,0)) operation.append((1,idx2,0)) operation.append((2,idx2,0)) a[idx2],b[0]=b[0],a[idx2] idx=0 for i in range(n): if a[i]==b_min: operation.append((1,i,idx)) a[i]=0 hq1=[] for i in range(n): heapq.heappush(hq1,(-a[i],i)) hq2=[] for i in range(n): heapq.heappush(hq2,(b[i],i)) while -hq1[0][0]>=hq2[0][0]: x,p=heapq.heappop(hq1) y,q=heapq.heappop(hq2) operation.append((1,p,q)) operation.append((2,p,q)) operation.append((1,p,q)) a[p],b[q]=b[q],a[p] print(len(operation)) for t,p,q in operation: print(t,p+1,q+1)