結果
問題 | No.862 XORでX |
ユーザー |
![]() |
提出日時 | 2019-08-09 23:03:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,639 bytes |
コンパイル時間 | 1,903 ms |
コンパイル使用メモリ | 173,336 KB |
実行使用メモリ | 8,192 KB |
最終ジャッジ日時 | 2024-07-19 15:30:30 |
合計ジャッジ時間 | 6,773 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 16 WA * 1 RE * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, x; cin >> n >> x; if (n == 2) { if (x == 1) { cout << 2 << '\n'; cout << 3 << '\n'; } else { cout << 1 << '\n'; cout << (x ^ 1) << '\n'; } return 0; } set<int> res; auto add = [&](int l, int r) -> void { for (int i = l; i < r; ++i) { res.insert(i); } }; assert(n % 4 <= 1); if (n % 4 == 0) { if (x < 4) { add(1, n + 4); res.erase(4 | x); res.erase(8); res.erase(12); } else { add(1, 4); int m = n / 4 - 1; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } res.insert(x); } } else if (n % 4 == 1) { int m = n / 4; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } res.insert(x); } else if (n % 4 == 2) { for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.insert(i); } add(1, 4); int m = n / 4; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } } else { for (int i = x / 4 * 4; i < x / 4 * 4 + 4; ++i) if (i != x) { res.insert(i); } int m = n / 4; for (int i = 4; m; i += 4) { if (i <= x and x < i + 4) continue; add(i, i + 4); --m; } } for (int e : res) { cout << e << '\n'; } }