結果
問題 | No.1228 I hate XOR Matching |
ユーザー |
|
提出日時 | 2020-09-12 09:17:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 832 bytes |
コンパイル時間 | 2,349 ms |
コンパイル使用メモリ | 196,376 KB |
最終ジャッジ日時 | 2025-01-14 13:14:07 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int k, x; cin >> k >> x; if (x == 0) { cout << "Yes" << endl; cout << 1 << endl; cout << (k ^ 1) << endl; return 0; } if (k == 0) x++; bool ok = false; for (int i = 0; i <= 30; i++) if ((1 << i) == x) ok = true; if (!ok) { cout << "No" << endl; return 0; } vector<int> ans; for (int i = 1; x > 1; i++) { ans.push_back(i); if (__builtin_popcount(i) != 1) x >>= 1; } if (k > 0 && (ans.empty() || __builtin_clz(ans.back()) > __builtin_clz(k))) ans.push_back(k); cout << "Yes" << endl; cout << ans.size() << endl; for (int i = 0; i < (int) ans.size(); i++) { if (i > 0) cout << " "; cout << ans[i]; } cout << endl; return 0; }