結果
問題 |
No.1896 Arrays and XOR Procedure 2
|
ユーザー |
![]() |
提出日時 | 2022-04-09 17:20:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,160 bytes |
コンパイル時間 | 247 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 82,488 KB |
最終ジャッジ日時 | 2024-11-29 17:16:15 |
合計ジャッジ時間 | 8,289 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 6 |
ソースコード
#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect import heapq import functools mod=10**9+7 import sys input=sys.stdin.readline n=int(input()) a=list(map(int,input().split())) heapa = [] b=list(map(int,input().split())) heapb = [] for i in range(n): heapa.append([-a[i],i+1]) heapb.append([b[i],i+1]) heapq.heapify(heapa) heapq.heapify(heapb) ans = [] cnt = 0 while True: maa,aind = heapq.heappop(heapa) maa = -maa mib,bind = heapq.heappop(heapb) #print(maa,mib) if maa < mib: break if maa == mib: ans.append([1,aind,bind]) #a[aind-1] ^= b[bind-1] heapq.heappush(heapa,[0,aind]) heapq.heappush(heapb,[maa,bind]) else: ans.append([1,aind,bind]) #a[aind-1] ^= b[bind-1] ans.append([2,aind,bind]) #b[bind-1] ^= a[aind-1] ans.append([1,aind,bind]) #a[aind-1] ^= b[bind-1] heapq.heappush(heapa,[-mib,aind]) heapq.heappush(heapb,[maa,bind]) print(len(ans)) for row in ans: print(*row)