Submission #1000811
Source Code Expand
#include <cstdio>
#include <cmath>
#include <algorithm>
typedef long long signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(int i = (l) ; i < (r); i++)
#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) < (r))
template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
// ---- ----
int n, a[100000];
int solve() {
int eor = 0;
inc(i, n) { eor ^= a[i]; }
int flag = 0;
dec(i, 30) {
if(flag == 0) {
if(eor & (1 << i)) { flag = 1; }
} else {
if(eor & (1 << i)) { flag = 0; }
eor ^= (1 << i);
}
}
int ans = 0;
inc(i, 30) {
if(eor & (1 << i)) {
bool f2 = false;
inc(j, n) {
if( (i != 0 && a[j] == (1 << i)) || (i == 0 && a[j] % 2 != 0)) { f2 = true; break; }
}
if(f2) { ans++; } else { return -1; }
}
}
return ans;
}
int main() {
scanf("%d", &n);
inc(i, n) { scanf("%d", &a[i]); }
printf("%d\n", solve());
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Cheating Nim |
User |
FF256grhy |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1909 Byte |
Status |
WA |
Exec Time |
13 ms |
Memory |
512 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:63:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:64:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
inc(i, n) { scanf("%d", &a[i]); }
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
example0.txt, example1.txt |
All |
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 |
Case Name |
Status |
Exec Time |
Memory |
000.txt |
AC |
1 ms |
128 KB |
001.txt |
AC |
1 ms |
128 KB |
002.txt |
AC |
13 ms |
512 KB |
003.txt |
WA |
6 ms |
384 KB |
004.txt |
AC |
6 ms |
384 KB |
005.txt |
AC |
5 ms |
256 KB |
006.txt |
WA |
13 ms |
512 KB |
007.txt |
WA |
13 ms |
512 KB |
008.txt |
WA |
13 ms |
512 KB |
009.txt |
WA |
13 ms |
512 KB |
010.txt |
WA |
13 ms |
512 KB |
011.txt |
WA |
13 ms |
512 KB |
012.txt |
WA |
13 ms |
512 KB |
013.txt |
WA |
13 ms |
512 KB |
014.txt |
WA |
13 ms |
512 KB |
015.txt |
WA |
13 ms |
512 KB |
016.txt |
AC |
13 ms |
512 KB |
017.txt |
AC |
13 ms |
512 KB |
018.txt |
WA |
13 ms |
512 KB |
019.txt |
WA |
13 ms |
512 KB |
020.txt |
AC |
13 ms |
512 KB |
021.txt |
AC |
2 ms |
256 KB |
022.txt |
AC |
2 ms |
256 KB |
023.txt |
AC |
13 ms |
512 KB |
example0.txt |
WA |
1 ms |
128 KB |
example1.txt |
AC |
1 ms |
128 KB |