結果

問題 No.862 XORでX
ユーザー beetbeet
提出日時 2019-08-09 23:04:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,516 bytes
コンパイル時間 2,396 ms
コンパイル使用メモリ 207,860 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-26 21:42:44
合計ジャッジ時間 7,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, Int> dict(const vector<T> &v){
  map<T, Int> res;
  for(Int i=0;i<(Int)v.size();i++)
    res[v[i]]=i;
  return res;
}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,x;
  cin>>n>>x;
  vector<Int> as;
  if(x<=3){
    assert(0);
  }else{
    Int p=x/4*4;
    assert(p>=4);
    if(n%4==0){
      as.emplace_back(x);
      as.emplace_back(1);
      as.emplace_back(2);
      as.emplace_back(3);
    }
    if(n%4==1){
      as.emplace_back(x);
    }
    if(n%4==2){
      if(x&1){
        as.emplace_back(p);
        as.emplace_back(x^p);
      }else{
        as.emplace_back(p+3);
        as.emplace_back(x^(p+3));
      }
    }
    if(n%4==3){
      for(Int k=0;k<4;k++)
        if(p+k!=x) as.emplace_back(p+k);
    }
    for(Int i=4;(Int)as.size()!=n;i+=4){
      if(i==p) continue;
      as.emplace_back(i+0);
      as.emplace_back(i+1);
      as.emplace_back(i+2);
      as.emplace_back(i+3);
    }
  }
  as=compress(as);
  assert((Int)as.size()==n);
  for(Int a:as) cout<<a<<"\n",x^=a;
  cout<<flush;
  assert(x==0);
  return 0;
}
0