結果

問題 No.1228 I hate XOR Matching
ユーザー msm1993msm1993
提出日時 2020-10-08 10:04:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 170,568 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-27 11:41:25
合計ジャッジ時間 6,097 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,564 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0