結果

問題 No.3223 K-XOR Increasing Sequence
ユーザー Carpenters-Cat
提出日時 2025-08-01 23:06:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 196,152 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-08-01 23:06:43
合計ジャッジ時間 14,070 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 58 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (Y == 0) {
		puts("No");
		return 0;
	}
	if (K == 1) {
		int lst = X + (N - 1);
		if (Y < lst) {
			puts("No");
		} else {
			puts("Yes");
			for (int i = 0; i < N-1; i ++) {
				cout << X + i << " ";
			}
			cout << Y << endl;
		}
		return 0;
	}
	puts("Yes");
	std::vector<int> ans(N, 1);
	ans[0] = X;
	if (K & 1) {
		ans[1] = 1; ans[2] = X ^ 1;
		if (ans[2] == 0) {
			ans[1] = 2; ans[2] = X ^ 2;
		}
		for (int i = 3; i < K; i ++) ans[i] = 1;
	} else {
		ans[1] = X;
		for (int i = 2; i < K; i ++) ans[i] = 1;
	}
	ans.back() = Y;
	for (int i = K; i < N-1; i ++) {
		ans[i] = ans[i-K];
	}
	for (int& a : ans) cout << a << " ";
	cout << endl;
}
0