結果

問題 No.862 XORでX
ユーザー fumofumofunifumofumofuni
提出日時 2022-07-18 00:55:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,345 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 202,520 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-12 12:53:38
合計ジャッジ時間 9,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
int main(){
  ll n,x;cin >> n >> x;
  if(n>=4&&x>=4){
    vl ans;
    if(n%4==0){
      ans.emplace_back(1);
      ans.emplace_back(2);
      ans.emplace_back(3);
      ans.emplace_back(x);
    }
    else if(n%4==1){
      ans.emplace_back(x);
    }
    else if(n%4==2){
      ans.emplace_back(1);
      ans.emplace_back(2);
      ans.emplace_back(3);
      ll base=x/4*4;
      rep(j,4){
        if(j+base==x)continue;
        ans.emplace_back(j+base);
      }
    }
    else{
      ll base=x/4*4;
      rep(j,4){
        if(j+base==x)continue;
        ans.emplace_back(j+base);
      }
    }
    for(ll i=4;i<=100000;i+=4){
      ll base=x/4*4;if(i==base)continue;
      if(ans.size()<n){
        rep(j,4)ans.emplace_back(i+j);
      }
    }
    //for(auto p:ans)cout << p << endl;
    //cout << ans.size() << endl;
    //ll ret=0;for(auto p:ans)ret^=p;cout << ret << endl;
    return 0;
  }
  if(n==1){
    cout << x << endl;return 0;
  }
  if(n==2){
    if(x==1){
      cout << 2 << endl;
      cout << 3 << endl;
    }
    else{
      cout << 1 << endl;
      cout << (x^1) << endl;
    }
    return 0;
  }
  if(n==3){
    if(1<=x&&x<=3){
      cout << 4 << endl;
      cout << 8 << endl;
      cout << (4^8^x) << endl;
    }
    else{
      ll base=x/4*4;
      rep(j,4){
        if(j+base==x)continue;
        cout << j+base << endl;
      }
    }
    return 0;
  }
  assert(0);
} 
0