結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー yamakeyamake
提出日時 2022-04-08 22:27:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 170,740 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 00:55:01
合計ジャッジ時間 5,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<"\n";
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1.1e18;const int inf=1.01e9;
constexpr int MOD=1000000007;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }

signed main(){
  int n;cin>>n;
  vector<int> a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  int f=max(*max_element(a.begin(),a.end()),*max_element(b.begin(),b.end()));
  while(f!=(f&(-f)))f-=(f&(-f));
  int ai=-1;int bi=-1;
  rep(i,n){
    if(a[i]&f)ai=i;
    if(b[i]&f)bi=i;
  }
  vector<array<int,3>> res;
  if(ai==-1){
    ai=0;
    a[0]^=b[bi];
    res.push_back({1,1,bi+1});
  }
  else if(bi==-1){
    bi=0;
    b[0]^=a[ai];
    res.push_back({2,ai+1,1});
  }
  rep(i,n){
    if((a[i]&f)>0&&i!=ai){
      a[i]^=b[bi];
      res.push_back({1,i+1,bi+1});
    }
    if((b[i]&f)==0){
      b[i]^=a[ai];
      res.push_back({2,ai+1,i+1});
    }
  }
  a[ai]^=b[bi];
  res.push_back({1,ai+1,bi+1});
  cout<<res.size()<<"\n";
  rep(i,res.size()){
    rep(j,3)cout<<res[i][j]<<" ";
    cout<<"\n";
  }
  return 0;
}
0