結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー tamatotamato
提出日時 2022-04-08 21:46:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-05-06 07:19:43
合計ジャッジ時間 6,287 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 34 ms
51,712 KB
testcase_03 AC 65 ms
75,008 KB
testcase_04 AC 73 ms
77,264 KB
testcase_05 AC 75 ms
77,184 KB
testcase_06 AC 68 ms
75,276 KB
testcase_07 AC 74 ms
77,184 KB
testcase_08 AC 73 ms
77,440 KB
testcase_09 AC 74 ms
77,184 KB
testcase_10 AC 73 ms
77,380 KB
testcase_11 AC 74 ms
77,172 KB
testcase_12 AC 74 ms
77,336 KB
testcase_13 AC 75 ms
77,312 KB
testcase_14 AC 71 ms
77,312 KB
testcase_15 AC 73 ms
77,312 KB
testcase_16 AC 72 ms
77,272 KB
testcase_17 AC 74 ms
76,800 KB
testcase_18 AC 67 ms
72,192 KB
testcase_19 AC 52 ms
65,024 KB
testcase_20 AC 73 ms
77,164 KB
testcase_21 AC 51 ms
64,896 KB
testcase_22 AC 74 ms
77,004 KB
testcase_23 AC 75 ms
76,880 KB
testcase_24 AC 75 ms
77,056 KB
testcase_25 AC 71 ms
76,984 KB
testcase_26 AC 73 ms
77,184 KB
testcase_27 AC 76 ms
77,056 KB
testcase_28 AC 67 ms
74,600 KB
testcase_29 AC 68 ms
74,880 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