結果
問題 | No.1228 I hate XOR Matching |
ユーザー |
![]() |
提出日時 | 2020-10-08 10:04:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 962 bytes |
コンパイル時間 | 1,903 ms |
コンパイル使用メモリ | 172,720 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 05:47:11 |
合計ジャッジ時間 | 6,446 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) vector<ULL> f(ULL X){ X+=1; if(X&(X-1)) return {}; ULL D = 1; vector<ULL> ans; rep(t,2) if(X>=(1ull<<1)){ ans.push_back(0); X>>=1; } while(X>=(1ull<<11)){ rep(k,7)rep(t,2) ans.push_back((k+1)*D); D<<=3; X>>=11; } while(X>=(1ull<<4)){ rep(k,3)rep(t,2) ans.push_back((k+1)*D); D<<=2; X>>=4; } while(X>=(1ull<<1)){ rep(t,2) ans.push_back(1*D); D<<=1; X>>=1; } ans.push_back(D); return ans; } int main() { ULL K,X; cin>>K>>X; vector<ULL> ans; if(K==0) ans=f(X); else if(X==0){ ans={0}; } else{ ans=f(X-1); if(!ans.empty()){ ULL d = K&~(K-1); for(ULL& a : ans){ a = (a&(d-1)) | ((a&~(d-1))<<1); } ans.push_back(K); } } if(ans.empty()) cout<<"No"<<endl; else{ cout<<"Yes"<<endl; cout<<ans.size()<<endl; rep(i,ans.size()){ if(i) cout<<" "; cout<<ans[i]; } cout<<endl; } return 0; }