結果

問題 No.862 XORでX
ユーザー gratan_mogmoggratan_mogmog
提出日時 2019-08-09 22:59:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 2,376 bytes
コンパイル時間 1,673 ms
コンパイル使用メモリ 173,316 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 21:36:57
合計ジャッジ時間 4,224 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 13 ms
4,380 KB
testcase_19 AC 13 ms
4,376 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 11 ms
4,376 KB
testcase_22 AC 10 ms
4,380 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 17 ms
4,376 KB
testcase_25 AC 11 ms
4,376 KB
testcase_26 AC 10 ms
4,380 KB
testcase_27 AC 17 ms
4,376 KB
testcase_28 AC 17 ms
4,376 KB
testcase_29 AC 17 ms
4,376 KB
testcase_30 AC 17 ms
4,380 KB
testcase_31 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e17;
const char ENDL = '\n';

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,x;
    cin >> n >> x;
    if (x==1){
        vll ans;
        int k = 1;
        rep(i, (n - 1) / 4)
        {
            ans.eb(4 * k);
            ans.eb(4 * k + 1);
            ans.eb(4 * k + 2);
            ans.eb(4 * k + 3);
            k++;
        }
        if (n % 4 == 0)
        {
            ans.eb(1e5);
            ans.eb(1e5 + 2);
            ans.eb(2);
            ans.eb(x);
        }
        if (n % 4 == 1)
        {
            ans.eb(x);
        }
        if (n % 4 == 2)
        {
            ans.eb(1e5 + 4);
            ans.eb(1e5 + 5);
        }
        if (n % 4 == 3)
        {
            ans.eb(3);
            ans.eb(1e5);
            ans.eb(1e5 + 2);
        }
        sort(all(ans));
        rep(i, n) cout << ans[i] << ENDL;
        return 0;
    }
    vll ans;
    int k = 1;
    rep(i,(n-1)/4){
        if (4*k<=x && x<4*(k+1)){
            k++;
        }
        ans.eb(4 * k);
        ans.eb(4 * k+1);
        ans.eb(4 * k+2);
        ans.eb(4 * k+3);
        k++;
    }
    if (n%4==0)
    {
        ans.eb(1e5 + 4);
        ans.eb(1e5 + 5);
        ans.eb(1);
        ans.eb(x);
    }
    if (n%4==1){
        ans.eb(x);
    }
    if (n%4==2){
        ans.eb(x ^ 1);
        ans.eb(1);
    }
    if (n%4==3){
        ans.eb(x ^ 1);
        ans.eb(1e5 + 4);
        ans.eb(1e5 + 5);
    }
    sort(all(ans));
    rep(i, n) cout << ans[i] << ENDL;
}
0