結果

問題 No.862 XORでX
ユーザー face4face4
提出日時 2019-10-18 17:31:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 3,045 ms
コンパイル使用メモリ 71,096 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 20:59:08
合計ジャッジ時間 5,646 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 16 ms
4,384 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 91 ms
4,376 KB
testcase_17 AC 90 ms
4,376 KB
testcase_18 AC 91 ms
4,380 KB
testcase_19 AC 88 ms
4,376 KB
testcase_20 AC 123 ms
4,380 KB
testcase_21 AC 121 ms
4,380 KB
testcase_22 AC 121 ms
4,380 KB
testcase_23 AC 124 ms
4,376 KB
testcase_24 AC 118 ms
4,380 KB
testcase_25 AC 133 ms
4,380 KB
testcase_26 AC 128 ms
4,384 KB
testcase_27 AC 123 ms
4,380 KB
testcase_28 AC 126 ms
4,380 KB
testcase_29 AC 125 ms
4,376 KB
testcase_30 AC 124 ms
4,376 KB
testcase_31 AC 122 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    }
}
0