結果

問題 No.862 XORでX
ユーザー tarattata1tarattata1
提出日時 2019-08-09 23:22:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,877 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 75,792 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-26 22:05:25
合計ジャッジ時間 4,566 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int solve( int n, int x, vector<int>& ans)
{

    int k=(n-1)%4;
    int n2=(n-1)/4;

    if(k==0) {
        //nothing
    }
    else if(k==1) {
        ans.push_back(1);
        x = (x^1);
    }
    else if(k==2) {
        ans.push_back(1);
        ans.push_back(2);
        x = (x^3);
    }
    else if(k==3) {
        ans.push_back(1);
        ans.push_back(2);
        ans.push_back(3);
    }
    ans.push_back(x);

    if(n2>0) {
        int i;
        int cnt=0;
        for(i=1; i<=n2+1; i++) {
            int t;
            for(t=0; t<4; t++) {
                if(i*4+t==x) break;
            }
            if(t==4) {
                for(t=0; t<4; t++) {
                    ans.push_back(i*4+t);
                }
                cnt++;
            }
            if(cnt==n2) break;
        }
    }
    
    return 0;
}

int main(int argc, char* argv[])
{
#if 1
    int n,x;
    scanf("%d%d", &n, &x);

    vector<int> ans;
    solve(n, x, ans);
    int i;
    for(i=0; i<(int)ans.size(); i++) {
        printf("%d\n", ans[i]);
    }
#else
    int i,j;
    for(i=99990; i<=100000; i++) {
        for(j=99990; j<=100000; j++) {
            vector<int> ans;
            solve(i,j,ans);
            int k;
            int val=0;
            for(k=0; k<(int)ans.size(); k++) {
                val = (val^ans[k]);
            }
            assert(val==j);
        }
    }

#endif
    return 0;
}
0