結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ShirotsumeShirotsume
提出日時 2022-02-07 12:07:14
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,676 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,824 KB
最終ジャッジ日時 2024-05-06 00:46:55
合計ジャッジ時間 8,340 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, a, b):
    ans = []
    c = sorted(a + b)
    minb = c[n]
    cnt = 0
    for i in range(n):
        if c[i] == minb:
            cnt += 1
    if cnt > 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 cnt > 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]

    for i in range(cnt - 1):
        if a.count(minb) > 1:
            p = a.index(minb)
            q = b.index(minb)
            ans.append((1, p + 1, q + 1))
            a[p] = 0
        elif b.count(minb) >= 1:
            p = a.index(minb)
            q = b.index(minb)
            ans.append((2, p + 1, q + 1))
            b[q] = 0
    while max(a) >= min(b):
        p = a.index(max(a))
        q = b.index(min(b))
        if min(b) == 0:
            ans.append((2, p + 1, q + 1))
            ans.append((1, p + 1, q + 1))
            a[p], b[q] = b[q], a[p]
        elif max(a) == min(b):
            ans.append((1, p + 1, q + 1))
            a[p] = 0
        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)
print("無駄な出力")
0