結果

問題 No.1228 I hate XOR Matching
ユーザー leaf_1415
提出日時 2020-09-11 22:24:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,584 bytes
コンパイル時間 1,033 ms
コンパイル使用メモリ 79,760 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-27 15:29:29
合計ジャッジ時間 9,247 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 15 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define PI 3.1415926535897932384626433832795028841971
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint k, x;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> k >> x;
	
	if(k == 0){
		if(x == 0){
			cout << "Yes" << endl;
			cout << 1 << endl;
			cout << 1 << endl;
			return 0;
		}
		if((x+1)&x){
			cout << "No" << endl;
			return 0;
		}
		llint r = 0;
		x++;
		for(;x;x/=2) r++;
		r--;
		
		cout << "Yes" << endl;
		cout << 2*r << endl;
		for(int i = 0; i < r; i++){
			cout << (1<<i) << " " << (1<<i) << " ";
		}
		cout << endl;
		return 0;
	}
	
	if(x == 0){
		cout << "Yes" << endl;
		cout << 1 << endl;
		cout << 0 << endl;
		return 0;
	}
	if((x-1)&x){
		cout << "No" << endl;
		return 0;
	}
	
	llint r = 0;
	for(;x;x/=2) r++;
	r--;
	
	cout << "Yes" << endl;
	cout << 2*r+1 << endl;
	for(int i = 0; i < r; i++){
		if(k&(k-1)) cout << (1<<i) << " " << (1<<i) << " ";
		else cout << (1<<20)-1-(1<<i) << " " << (1<<20)-1-(1<<i) << " ";
	}
	cout << k << endl;
	cout << endl;
	
	return 0;
}
0