結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー siganaisiganai
提出日時 2022-04-09 17:33:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 1,419 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 84,604 KB
最終ジャッジ日時 2023-08-19 21:35:15
合計ジャッジ時間 12,086 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
78,676 KB
testcase_01 AC 135 ms
78,732 KB
testcase_02 AC 135 ms
78,728 KB
testcase_03 AC 251 ms
83,116 KB
testcase_04 AC 222 ms
82,992 KB
testcase_05 AC 226 ms
83,664 KB
testcase_06 AC 228 ms
83,304 KB
testcase_07 AC 225 ms
83,056 KB
testcase_08 AC 228 ms
83,564 KB
testcase_09 AC 225 ms
83,152 KB
testcase_10 AC 235 ms
83,460 KB
testcase_11 AC 225 ms
83,300 KB
testcase_12 AC 224 ms
83,620 KB
testcase_13 AC 249 ms
84,088 KB
testcase_14 AC 241 ms
84,284 KB
testcase_15 AC 233 ms
83,280 KB
testcase_16 AC 234 ms
83,408 KB
testcase_17 AC 237 ms
83,476 KB
testcase_18 AC 215 ms
83,020 KB
testcase_19 AC 181 ms
81,352 KB
testcase_20 AC 233 ms
83,684 KB
testcase_21 AC 185 ms
81,588 KB
testcase_22 AC 287 ms
84,512 KB
testcase_23 AC 245 ms
84,604 KB
testcase_24 AC 244 ms
83,928 KB
testcase_25 AC 242 ms
83,884 KB
testcase_26 AC 252 ms
84,456 KB
testcase_27 AC 250 ms
84,568 KB
testcase_28 AC 228 ms
83,084 KB
testcase_29 AC 226 ms
83,576 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,[maa,bind])          
                 
print(len(ans))
for row in ans:
    print(*row)
    
0