結果
問題 | No.1228 I hate XOR Matching |
ユーザー |
|
提出日時 | 2020-09-12 00:43:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 923 bytes |
コンパイル時間 | 876 ms |
コンパイル使用メモリ | 73,072 KB |
最終ジャッジ日時 | 2025-01-14 12:35:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <iostream> #include <vector> void solve() { int k, x; std::cin >> k >> x; if (x == 0) { std::cout << "Yes\n" << 1 << "\n" << (k == 0 ? 1 : 0) << "\n"; return; } if (k == 0) ++x; if (__builtin_popcount(x) != 1) { std::cout << "No\n"; return; } int p = __builtin_ctz(x); std::vector<int> ans; // 線形独立なものを加える for (int i = 0; i < 5; ++i) ans.push_back(1 << i); // kが従属じゃなければ追加 if (k >= (1 << 5)) ans.push_back(k); // 線形従属なものを追加 for (int q = 0; q < p; ++q) ans.push_back(q); std::cout << "Yes\n" << ans.size() << "\n"; for (auto a : ans) std::cout << a << " "; std::cout << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }