結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー SSRSSSRS
提出日時 2022-04-08 21:33:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,477 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 206,160 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-19 00:13:57
合計ジャッジ時間 6,081 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++){
    cin >> B[i];
  }
  int h = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 30; j++){
      if ((A[i] >> j & 1) == 1){
        h = max(h, j);
      }
      if ((B[i] >> j & 1) == 1){
        h = max(h, j);
      }
    }
  }
  vector<int> ap, bp;
  vector<bool> ah(N, false), bh(N, false);
  for (int i = 0; i < N; i++){
    if ((A[i] >> h & 1) == 1){
      ap.push_back(i);
      ah[i] = true;
    }
    if ((B[i] >> h & 1) == 1){
      bp.push_back(i);
      bh[i] = true;
    }
  }
  int K = 0;
  vector<int> T, P, Q;
  if (!ah[0]){
    int x = bp[0];
    K++;
    T.push_back(1);
    P.push_back(0);
    Q.push_back(x);
    ah[0] = true;
  }
  if (!bh[0]){
    int x = ap[0];
    K++;
    T.push_back(2);
    P.push_back(x);
    Q.push_back(0);
    bh[0] = true;
  }
  for (int i = 1; i < N; i++){
    if (ah[i]){
      K++;
      T.push_back(1);
      P.push_back(i);
      Q.push_back(0);
      ah[i] = false;
    }
  }
  for (int i = 1; i < N; i++){
    if (!bh[i]){
      K++;
      T.push_back(2);
      P.push_back(0);
      Q.push_back(i);
      bh[i] = true;
    }
  }
  K++;
  T.push_back(1);
  P.push_back(0);
  Q.push_back(0);
  cout << K << endl;
  for (int i = 0; i < K; i++){
    cout << T[i] << ' ' << P[i] + 1 << ' ' << Q[i] + 1 << endl;
  }
}
0