結果

問題 No.1228 I hate XOR Matching
ユーザー leaf_1415leaf_1415
提出日時 2020-09-11 22:55:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,220 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 80,028 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-08-27 16:18:22
合計ジャッジ時間 5,854 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,376 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:111:24: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   llint x = vec[i] % (1<<b);
                      ~~^~~~

ソースコード

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;
		vector<llint> vec;
		for(int i = 0; i < r/11; i++){
			for(int j = 1; j <= 7; j++){
				llint x = j<<(3*i);
				vec.push_back(x);
				vec.push_back(x);
			}
		}
		for(int i = 0; i < r%11; i++){
			vec.push_back(1<<(r/11*3+i));
			vec.push_back(1<<(r/11*3+i));
		}
		cout << vec.size() << endl;
		for(int i = 0; i < vec.size(); i++) cout << vec[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--;
	
	llint b;
	for(int i = 0; i < 20; i++){
		if(k & (1<<i)){
			b = i;
			break;
		}
	}
	
	cout << "Yes" << endl;
	vector<llint> vec;
	for(int i = 0; i < r/11; i++){
		for(int j = 1; j <= 7; j++){
			llint x = j<<(3*i);
			vec.push_back(x);
			vec.push_back(x);
		}
	}
	for(int i = 0; i < r%11; i++){
		vec.push_back(1<<(r/11*3+i));
		vec.push_back(1<<(r/11*3+i));
	}
	for(int i = 0; i < vec.size(); i++){
		llint x = vec[i] % (1<<b);
		vec[i] = (vec[i] >> b) << (b+1) + x;
	}
	vec.push_back(k);
	
	cout << vec.size() << endl;
	for(int i = 0; i < vec.size(); i++) cout << vec[i] << " "; cout << endl;
	
	cout << endl;
	
	return 0;
}
0