結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー roarisroaris
提出日時 2022-04-22 17:16:48
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 793 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 83,964 KB
最終ジャッジ日時 2023-09-06 03:17:18
合計ジャッジ時間 10,318 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,224 KB
testcase_01 AC 70 ms
71,084 KB
testcase_02 AC 72 ms
71,208 KB
testcase_03 RE -
testcase_04 AC 112 ms
79,356 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 110 ms
78,720 KB
testcase_09 AC 117 ms
78,708 KB
testcase_10 AC 115 ms
78,780 KB
testcase_11 AC 116 ms
78,760 KB
testcase_12 AC 110 ms
78,724 KB
testcase_13 AC 110 ms
78,800 KB
testcase_14 AC 117 ms
78,936 KB
testcase_15 AC 113 ms
78,680 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 102 ms
77,748 KB
testcase_19 AC 101 ms
76,804 KB
testcase_20 AC 106 ms
78,180 KB
testcase_21 AC 89 ms
76,608 KB
testcase_22 AC 113 ms
78,156 KB
testcase_23 AC 111 ms
77,940 KB
testcase_24 AC 111 ms
77,724 KB
testcase_25 AC 120 ms
77,912 KB
testcase_26 AC 111 ms
78,088 KB
testcase_27 AC 110 ms
78,088 KB
testcase_28 AC 101 ms
78,312 KB
testcase_29 AC 101 ms
78,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l = []

for i in range(N):
    l.append((A[i], i))
    l.append((B[i], i+N))

l.sort()
swap_a, swap_b = [], []

for _, i in l[:N]:
    if i>=N:
        swap_b.append(i-N)

for _, i in l[N:]:
    if i<N:
        swap_a.append(i)

ans = []

for i, j in zip(swap_a, swap_b):
    ans.append((1, i+1, j+1))
    ans.append((2, i+1, j+1))
    ans.append((1, i+1, j+1))
    A[i], B[j] = B[j], A[i]

M = max(A)
m = min(B)

if M==m:
    for i in range(N):
        if B[i]==m:
            for j in range(N):
                if A[j]==M:
                    ans.append((1, j+1, i+1))
            break

assert len(ans)<=10000
print(len(ans))

for ans_i in ans:
    print(*ans_i)
0