CODE FESTIVAL 2016 Grand Final

Submission #4118798

Source codeソースコード

#include<bits/stdc++.h>
#define rint register int
#define rep(i,a,b) for (rint i=(a),_E=(b); i<=_E; ++i)
#define per(i,a,b) for (rint i=(a),_E=(b); i>=_E; --i)
#define REP(i,n) for (rint i=0,_E=(n); i<_E; ++i)
#define pb push_back
#define cmin(x,y) (y<x?x=y:0)
#define cmax(x,y) (y>x?x=y:0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

const int N = 100005;
int c[32], x, n, res, cnt, ans;

int main() {
	scanf("%d", &n);
	rep (i, 1, n) {
		scanf("%d", &x);
		res ^= x;
		cnt = 0;
		while (x && (x % 2 == 0))
			x >>= 1, ++ cnt;
		c[cnt] = 1;
	}
	per (i, 30, 0)
		if (res >> i & 1) {
			res ^= (1 << (i + 1)) - 1;
			++ ans;
			if (!c[i]) return puts("-1"), 0;
		}
	printf("%d\n", ans);
	return 0;
}

Submission

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

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

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

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 256 KB
003.txt AC 7 ms 256 KB
004.txt AC 6 ms 256 KB
005.txt AC 5 ms 256 KB
006.txt AC 15 ms 256 KB
007.txt AC 15 ms 256 KB
008.txt AC 15 ms 256 KB
009.txt AC 15 ms 256 KB
010.txt AC 15 ms 256 KB
011.txt AC 15 ms 256 KB
012.txt AC 15 ms 256 KB
013.txt AC 15 ms 256 KB
014.txt AC 15 ms 256 KB
015.txt AC 15 ms 256 KB
016.txt AC 15 ms 256 KB
017.txt AC 15 ms 256 KB
018.txt AC 15 ms 256 KB
019.txt AC 15 ms 256 KB
020.txt AC 15 ms 256 KB
021.txt AC 2 ms 256 KB
022.txt AC 2 ms 256 KB
023.txt AC 15 ms 256 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB