結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ShirotsumeShirotsume
提出日時 2021-12-22 12:20:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,685 bytes
コンパイル時間 381 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 82,968 KB
最終ジャッジ日時 2023-10-14 13:57:22
合計ジャッジ時間 12,093 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,228 KB
testcase_01 AC 76 ms
71,248 KB
testcase_02 AC 74 ms
71,188 KB
testcase_03 AC 230 ms
78,608 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 234 ms
78,912 KB
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 126 ms
77,948 KB
testcase_19 AC 110 ms
77,764 KB
testcase_20 AC 144 ms
78,648 KB
testcase_21 AC 108 ms
76,976 KB
testcase_22 AC 170 ms
78,464 KB
testcase_23 AC 164 ms
78,408 KB
testcase_24 AC 171 ms
78,424 KB
testcase_25 AC 162 ms
78,340 KB
testcase_26 AC 174 ms
78,536 KB
testcase_27 AC 170 ms
78,248 KB
testcase_28 AC 232 ms
79,160 KB
testcase_29 AC 233 ms
79,336 KB
権限があれば一括ダウンロードができます

ソースコード

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]
    times = a.count(minb) + b.count(minb)
    cnt0 = 0
    while times > 1 and cnt0 < n:
        cnt0 += 1
        times -= 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((2, p + 1, q + 1))
            ans.append((1, 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 i in range(n):
    for j in range(n):
        if a[i] >= b[j]:
            raise Exception
for t, i, j in ans:
    print(t, i, j)
0