結果
問題 |
No.862 XORでX
|
ユーザー |
|
提出日時 | 2019-10-18 17:31:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 877 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 71,680 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 14:40:14 |
合計ジャッジ時間 | 4,644 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#include<iostream> #include<vector> using namespace std; #define inRange(x,a,b) (a <= x && x <= b) int main(){ int n, x; cin >> n >> x; vector<int> ans; int pos = 2; if(x == 1) pos = 10; while(n-ans.size() > 4){ if(!inRange(x,pos,pos+3)){ for(int i = 0; i < 4; i++) ans.push_back(pos+i); } pos += 4; } int base = (x-2)/4*4+2; vector<int> res({1, base, base+1, base+2, base+3}); if(x == 1) res = vector<int>({1, 2, 3, 4, 7}); for(int i = 1; i < 1<<5; i++){ vector<int> tmp; int xo = 0; for(int j = 0; j < 5; j++){ if((i>>j)&1) tmp.push_back(res[j]), xo ^= res[j]; } if(tmp.size() != n-ans.size() || xo != x) continue; for(int j : tmp) ans.push_back(j); for(int j : ans) cout << j << endl; return 0; } }