結果
| 問題 | 
                            No.862 XORでX
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tarattata1
                         | 
                    
| 提出日時 | 2019-08-10 00:08:55 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,739 bytes | 
| コンパイル時間 | 659 ms | 
| コンパイル使用メモリ | 73,664 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-19 16:02:39 | 
| 合計ジャッジ時間 | 3,000 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 25 WA * 3 | 
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:106:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  106 |     scanf("%d%d", &n, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~
            
            ソースコード
#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;
    int stt=1;
    if(k==0) {
        ans.push_back(x);
    }
    else if(k==1) {
        ans.push_back(1);
        x = (x^1);
        ans.push_back(x);
    }
    else if(k==2) {
        if(x==1) {
            ans.push_back(5);
            ans.push_back(2);
            ans.push_back(6);
            stt++;
        }
        else if(x==2) {
            ans.push_back(1);
            ans.push_back(6);
            ans.push_back(5);
            stt++;
        }
        else {
            ans.push_back(1);
            ans.push_back(2);
            x = (x^3);
            ans.push_back(x);
        }
    }
    else if(k==3) {
        if(x<4) {
            if(x==1) {
                ans.push_back(4);
                ans.push_back(6);
                ans.push_back(2);
            }
            else {
                ans.push_back(4);
                ans.push_back(5);
                ans.push_back(1);
            }
            ans.push_back(x);
            stt++;
        }
        else {
            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=stt; 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=1; i<=100; i++) {
        for(j=1; j<=100; 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;
}
            
            
            
        
            
tarattata1