結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ShirotsumeShirotsume
提出日時 2021-12-22 14:28:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,778 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 80,468 KB
最終ジャッジ日時 2023-10-14 14:27:53
合計ジャッジ時間 10,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,444 KB
testcase_01 AC 69 ms
71,248 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 229 ms
79,116 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 183 ms
78,520 KB
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 121 ms
78,476 KB
testcase_19 AC 105 ms
78,284 KB
testcase_20 AC 139 ms
78,332 KB
testcase_21 AC 102 ms
78,028 KB
testcase_22 AC 172 ms
78,380 KB
testcase_23 AC 168 ms
78,596 KB
testcase_24 AC 175 ms
78,228 KB
testcase_25 AC 167 ms
78,292 KB
testcase_26 AC 177 ms
78,332 KB
testcase_27 AC 174 ms
78,496 KB
testcase_28 AC 139 ms
78,372 KB
testcase_29 AC 139 ms
78,704 KB
権限があれば一括ダウンロードができます

ソースコード

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 i in range(n):
    for j in range(n):
        if a[i] >= b[j]:
            print(a[i], b[j])
            raise Exception
for t, i, j in ans:
    print(t, i, j)
0