結果
問題 | No.862 XORでX |
ユーザー |
![]() |
提出日時 | 2019-08-09 23:04:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,516 bytes |
コンパイル時間 | 2,078 ms |
コンパイル使用メモリ | 202,848 KB |
最終ジャッジ日時 | 2025-01-07 11:33:06 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 RE * 13 |
ソースコード
#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; }