結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー 👑 tamatotamato
提出日時 2022-04-08 21:46:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2023-08-19 00:24:13
合計ジャッジ時間 7,975 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,488 KB
testcase_01 AC 70 ms
71,260 KB
testcase_02 AC 62 ms
71,352 KB
testcase_03 AC 90 ms
78,228 KB
testcase_04 AC 97 ms
78,896 KB
testcase_05 AC 94 ms
78,816 KB
testcase_06 AC 95 ms
77,828 KB
testcase_07 AC 91 ms
78,828 KB
testcase_08 AC 97 ms
78,652 KB
testcase_09 AC 97 ms
78,796 KB
testcase_10 AC 96 ms
78,760 KB
testcase_11 AC 94 ms
78,644 KB
testcase_12 AC 95 ms
78,828 KB
testcase_13 AC 94 ms
78,528 KB
testcase_14 AC 95 ms
78,796 KB
testcase_15 AC 94 ms
78,844 KB
testcase_16 AC 92 ms
78,660 KB
testcase_17 AC 93 ms
78,896 KB
testcase_18 AC 93 ms
77,596 KB
testcase_19 AC 76 ms
76,924 KB
testcase_20 AC 96 ms
78,204 KB
testcase_21 AC 78 ms
77,024 KB
testcase_22 AC 97 ms
77,944 KB
testcase_23 AC 98 ms
78,164 KB
testcase_24 AC 104 ms
78,324 KB
testcase_25 AC 96 ms
78,428 KB
testcase_26 AC 100 ms
78,136 KB
testcase_27 AC 94 ms
78,060 KB
testcase_28 AC 88 ms
77,964 KB
testcase_29 AC 90 ms
77,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

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

    ans = []

    max_bit = 0
    for a in A:
        max_bit = max(max_bit, a.bit_length() - 1)
    for b in B:
        max_bit = max(max_bit, b.bit_length() - 1)

    for j, b in enumerate(B):
        if b >> max_bit & 1:
            if A[0] >> max_bit & 1 == 0:
                ans.append((1, 1, j + 1))
                A[0] ^= b
    if A[0] >> max_bit & 1:
        ii = 0
    else:
        for i, a in enumerate(A):
            if a >> max_bit & 1:
                ii = i
                break
    for j, b in enumerate(B):
        if b >> max_bit & 1 == 0:
            ans.append((2, ii + 1, j + 1))
            B[j] ^= A[ii]
    for i, a in enumerate(A):
        if a >> max_bit & 1:
            ans.append((1, i + 1, 1))
            A[i] ^= B[0]

    assert max(A) < min(B)
    print(len(ans))
    for line in ans:
        print(*line)


if __name__ == '__main__':
    main()
0