CODE FESTIVAL 2016 Grand Final(Parallel)

Submission #1757514

Source codeソースコード

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    cin >> n;
    VI a(n);
    int s = 0;
    REP(i,n){
        scanf("%d", &a[i]);
        s ^= a[i];
    }

    VI d(31);
    REP(i,n){
        int x = 0;
        REP(j,31) if ((a[i] >> j) & 1) {x = j; break;}
        d[x] = 1;
    }

    // int p;
    // FORR(i,30,0) if ((s >> i) & 1){p = i; break;}

    // cout << s << endl;
    // REP(i,31) cout << d[i] << " ";
    // cout << endl;

    int ans = 0;
    FORR(i,30,0){
        int x = (s >> i) & 1;
        int y = (s >> (i+1)) & 1;
        if (x != y){
            ans++;
            if (!d[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;

    return 0;
}




Submission

Task問題 C - Cheating Nim
User nameユーザ名 TangentDay
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 500
Source lengthソースコード長 1374 Byte
File nameファイル名
Exec time実行時間 15 ms
Memory usageメモリ使用量 640 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:35:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0.txt,example1.txt
All 500 / 500 000.txt,001.txt,002.txt,003.txt,004.txt,005.txt,006.txt,007.txt,008.txt,009.txt,010.txt,011.txt,012.txt,013.txt,014.txt,015.txt,016.txt,017.txt,018.txt,019.txt,020.txt,021.txt,022.txt,023.txt,example0.txt,example1.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
000.txt AC 1 ms 256 KB
001.txt AC 1 ms 256 KB
002.txt AC 14 ms 640 KB
003.txt AC 7 ms 512 KB
004.txt AC 6 ms 384 KB
005.txt AC 5 ms 384 KB
006.txt AC 15 ms 640 KB
007.txt AC 15 ms 640 KB
008.txt AC 15 ms 640 KB
009.txt AC 15 ms 640 KB
010.txt AC 15 ms 640 KB
011.txt AC 15 ms 640 KB
012.txt AC 15 ms 640 KB
013.txt AC 15 ms 640 KB
014.txt AC 15 ms 640 KB
015.txt AC 15 ms 640 KB
016.txt AC 15 ms 640 KB
017.txt AC 15 ms 640 KB
018.txt AC 14 ms 640 KB
019.txt AC 15 ms 640 KB
020.txt AC 15 ms 640 KB
021.txt AC 2 ms 256 KB
022.txt AC 2 ms 256 KB
023.txt AC 15 ms 640 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB