結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ShirotsumeShirotsume
提出日時 2021-12-22 12:02:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 80,552 KB
最終ジャッジ日時 2023-10-14 13:56:10
合計ジャッジ時間 9,553 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,048 KB
testcase_01 AC 64 ms
71,468 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
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 AC 98 ms
78,132 KB
testcase_19 AC 86 ms
76,796 KB
testcase_20 AC 106 ms
78,456 KB
testcase_21 AC 87 ms
76,984 KB
testcase_22 AC 115 ms
78,676 KB
testcase_23 AC 115 ms
78,120 KB
testcase_24 AC 119 ms
78,476 KB
testcase_25 AC 119 ms
78,204 KB
testcase_26 AC 123 ms
78,556 KB
testcase_27 AC 117 ms
78,588 KB
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, a, b):
    ans = []
    c = sorted(a + b)
    minb = c[n]
    if c.count(minb) > 1 and minb not in a:
        p = a.index(max(a))
        q = b.index(minb)
        ans.append((1, p + 1, q + 1))
        ans.append((2, p + 1, q + 1))
        ans.append((1, p + 1, q + 1))
        a[p], b[q] = b[q], a[p]
    if c.count(minb) > 1 and minb not in b:
        p = a.index(minb)
        q = b.index(min(b))
        ans.append((1, p + 1, q + 1))
        ans.append((2, p + 1, q + 1))
        ans.append((1, p + 1, q + 1))
        a[p], b[q] = b[q], a[p]
    
    while a.count(minb) + b.count(minb) > 1:
        if b.count(minb) >= 1:
            p = a.index(minb)
            q = b.index(minb)
            ans.append((2, p + 1, q + 1))
            b[q] = 0
        elif a.count(minb) > 1:
            p = a.index(minb)
            q = b.index(minb)
            ans.append((1, p + 1, q + 1))
            a[p] = 0
    while max(a) > min(b):
        p = a.index(max(a))
        q = b.index(min(b))
        if min(b) == 0:
            ans.append((1, p + 1, q + 1))
            ans.append((2, p + 1, q + 1))
            a[p], b[q] = b[q], a[p]
        else:
            ans.append((1, p + 1, q + 1))
            ans.append((2, p + 1, q + 1))
            ans.append((1, p + 1, q + 1))
            a[p], b[q] = b[q], a[p]
    return ans
            


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = solve(n, a, b)
print(len(ans))
for t, i, j in ans:
    print(t, i, j)
0