結果
| 問題 |
No.1228 I hate XOR Matching
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2020-09-28 13:51:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 932 bytes |
| コンパイル時間 | 1,606 ms |
| コンパイル使用メモリ | 171,540 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 00:50:19 |
| 合計ジャッジ時間 | 5,770 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 WA * 1 |
ソースコード
#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{
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;
}
Nachia