結果
問題 | No.862 XORでX |
ユーザー |
|
提出日時 | 2022-07-18 00:55:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,345 bytes |
コンパイル時間 | 3,116 ms |
コンパイル使用メモリ | 198,160 KB |
最終ジャッジ日時 | 2025-01-30 09:48:42 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 3 WA * 15 RE * 10 |
ソースコード
#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); }