結果

問題 No.862 XORでX
ユーザー ttttan2ttttan2
提出日時 2019-08-10 00:04:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 2,722 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 148,524 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 22:15:53
合計ジャッジ時間 6,136 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 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 2 ms
4,380 KB
testcase_08 AC 16 ms
4,380 KB
testcase_09 AC 15 ms
4,380 KB
testcase_10 AC 15 ms
4,380 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 100 ms
4,376 KB
testcase_17 AC 98 ms
4,380 KB
testcase_18 AC 98 ms
4,376 KB
testcase_19 AC 98 ms
4,380 KB
testcase_20 AC 131 ms
4,376 KB
testcase_21 AC 132 ms
4,376 KB
testcase_22 AC 131 ms
4,376 KB
testcase_23 AC 131 ms
4,376 KB
testcase_24 AC 128 ms
4,376 KB
testcase_25 AC 131 ms
4,376 KB
testcase_26 AC 128 ms
4,380 KB
testcase_27 AC 131 ms
4,380 KB
testcase_28 AC 130 ms
4,376 KB
testcase_29 AC 130 ms
4,376 KB
testcase_30 AC 131 ms
4,380 KB
testcase_31 AC 134 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ll n,x;cin>>n>>x;
    vector<ll> ans;
    ll now=n;
    ll k=(x/4)*4;
    for(int i=4;;i+=4){
        if(now<=4)break;
        if(i<x&&i+4>x)continue;
        if(i==x)continue;
        rep(j,0,4)ans.push_back(i+j);
        now-=4;
    }
    if(now%4==0){
        if(x>=4){
            rep(i,0,3) ans.push_back(i+1);
            ans.push_back(x);
        }
        else{
            if(x!=3){
                ans.push_back(100001);
                ans.push_back(100002);
                ans.push_back(3);
                ans.push_back(x);
            }
            else{
                ans.push_back(100003);
                ans.push_back(100001);
                ans.push_back(2);
                ans.push_back(3);
            }
        }
    }
    else if(now%4==1){
        ans.push_back(x);
        
    }
    else if(now%4==2){
        if(x>=4){
            if(k!=x){
                ans.push_back(k);
                ans.push_back(x);
            }
            else{
                ans.push_back(k+1);
                ans.push_back(1);
            }
        }
        else{
            rep(j,1,4){
                if(j!=x)ans.push_back(j);
            }
        }
    }
    else if(now%4==3){
        if(x>=4){
            if(k!=x){
                ans.push_back(k);
                ll u=k^x;
                rep(j,1,4)if(j!=u)ans.push_back(j);
            }
            else{
                ans.push_back(k+3);
                ans.push_back(1);
                ans.push_back(2);
            }
        }
        else{
            if(x!=3){
                ans.push_back(100001);
                ans.push_back(100002);
                if(x==1)ans.push_back(2);
                if(x==2)ans.push_back(1);
            }
            else{
                ans.push_back(100000);
                ans.push_back(100001);
                ans.push_back(2);
            }
        }
    }
    ll sum=0;
    rep(i,0,ans.size()){
      cout<<ans[i]<<endl;
        sum^=ans[i];
    }
    //cout<<sum<<endl;
}
0