結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー siganaisiganai
提出日時 2022-04-09 17:28:57
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,414 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 86,576 KB
実行使用メモリ 83,740 KB
最終ジャッジ日時 2023-08-19 21:30:04
合計ジャッジ時間 14,451 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
78,632 KB
testcase_01 AC 155 ms
78,548 KB
testcase_02 AC 152 ms
78,640 KB
testcase_03 AC 261 ms
82,964 KB
testcase_04 AC 243 ms
83,084 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 252 ms
83,184 KB
testcase_29 AC 256 ms
83,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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,[a,bind])          
                 
print(len(ans))
for row in ans:
    print(*row)
    
0