結果
問題 |
No.1228 I hate XOR Matching
|
ユーザー |
![]() |
提出日時 | 2020-09-11 23:17:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,840 bytes |
コンパイル時間 | 1,711 ms |
コンパイル使用メモリ | 171,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 20:04:55 |
合計ジャッジ時間 | 15,302 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 18 WA * 13 |
ソースコード
#include<bits/stdc++.h> using namespace std; //#define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' #define vec vector<ll> #define mat vector<vector<ll> > #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; typedef long double ld; typedef complex<double> comp; const ll INF=1e9+7; const ll MOD=998244353; const int MAX=200010; signed main(){ cin.tie(0); ios::sync_with_stdio(false); ll k,x;cin>>k>>x; vector<ll>beki(41); beki[0]=1; REP(i,1,41){ beki[i]=beki[i-1]*2LL; } if(x==0){ cout<<"Yes"<<endl; cout<<1<<endl; cout<<(k+1)%beki[20]<<endl; return 0; } if(k==0){ ll ans=-1; rep(i,22){ if(beki[i]-1==x)ans=i; } if(ans<0){ cout<<"No"<<endl; }else{ cout<<"Yes"<<endl; vector<ll>res(0); if(ans==1){ cout<<1<<endl; cout<<0<<endl; } else if(ans==2){ cout<<2<<endl; cout<<0<<' '<<0<<endl; }else{ ans-=2; res.pb(0); res.pb(0); ll now=0; rep(i,ans){ res.pb(1LL<<now); res.pb(1LL<<now); now++; } cout<<res.size()<<endl; rep(i,res.size()){ cout<<res[i]<<' '; } cout<<endl; } } }else{ ll ans=-1; rep(i,21){ if(beki[i]==x){ ans=i; break; } } if(ans<0){ cout<<"No"<<endl; }else{ cout<<"Yes"<<endl; if(ans==0){ cout<<1<<endl; cout<<k<<endl; }if(ans==1){ cout<<1<<endl; cout<<k<<' '<<0<<endl; }else{ vector<ll>res(0); res.pb(k); res.pb(0); res.pb(0); ans-=2; ll mi=0; while(((1LL<<mi)&k)==0){ mi++; } ll now=0; rep(i,ans){ if(mi==now)now++; res.pb(1LL<<now); res.pb(1LL<<now); now++; } cout<<res.size()<<endl; rep(i,res.size()){ cout<<res[i]<<' '; } cout<<endl; } } } }