結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー 👑 NachiaNachia
提出日時 2022-04-08 21:32:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,082 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 82,732 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 00:13:01
合計ジャッジ時間 6,677 ms
ジャッジサーバーID
(参考情報)
judge9 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
    int N; cin >> N;
    vector<i64> A(N);
    rep(i,N) cin >> A[i];
    vector<i64> B(N);
    rep(i,N) cin >> B[i];

    int maxAi = max_element(A.begin(), A.end()) - A.begin();
    i64 maxAibit = 1;
    while(A[maxAi] >= maxAibit * 2) maxAibit *= 2;

    vector<vector<int>> ans;
    rep(i,N){
        if(!(B[i] & maxAibit)){
            ans.push_back({ 2, maxAi+1, i+1 });
            B[i] ^= A[maxAi];
        }
    }
    rep(i,N){
        if(A[i] & maxAibit){
            ans.push_back({ 1, i+1, 1 });
            A[i] ^= B[0];
        }
    }

    cout << ans.size() << '\n';
    for(auto& a : ans){
        cout << a[0] << ' ' << a[1] << ' ' << a[2] << '\n';
    }
    return 0;
}

struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0