結果
| 問題 |
No.1896 Arrays and XOR Procedure 2
|
| コンテスト | |
| ユーザー |
siganai
|
| 提出日時 | 2022-04-09 17:33:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 186 ms / 2,000 ms |
| コード長 | 1,419 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 82,436 KB |
| 実行使用メモリ | 81,072 KB |
| 最終ジャッジ日時 | 2024-11-29 17:42:56 |
| 合計ジャッジ時間 | 8,528 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#!/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:
xor = maa ^ mib
if xor > maa:
ans.append([2,aind,bind])
heapq.heappush(heapa,[-maa,aind])
heapq.heappush(heapb,[xor,bind])
elif xor < mib:
ans.append([1,aind,bind])
heapq.heappush(heapa,[-xor,aind])
heapq.heappush(heapb,[mib,bind])
else:
ans.append([1,aind,bind])
ans.append([2,aind,bind])
heapq.heappush(heapa,[-xor,aind])
heapq.heappush(heapb,[maa,bind])
print(len(ans))
for row in ans:
print(*row)
siganai