Submission #2708199
Source Code Expand
int check[30]; int main() { for (int bit = 29; bit >= 0; bit--) { check[bit] = 0; } int n; scanf("%d", &n); int xor_sum = 0; int a; for (int i = 0; i < n; i++) { scanf("%d", &a); xor_sum ^= a; a = a ^ (a - 1); switch (a) { case 1073741823: check[29] = 1; break; case 536870911: check[28] = 1; break; case 268435455: check[27] = 1; break; case 134217727: check[26] = 1; break; case 67108863: check[25] = 1; break; case 33554431: check[24] = 1; break; case 16777215: check[23] = 1; break; case 8388607: check[22] = 1; break; case 4194303: check[21] = 1; break; case 2097151: check[20] = 1; break; case 1048575: check[19] = 1; break; case 524287: check[18] = 1; break; case 262143: check[17] = 1; break; case 131071: check[16] = 1; break; case 65535: check[15] = 1; break; case 32767: check[14] = 1; break; case 16383: check[13] = 1; break; case 8191: check[12] = 1; break; case 4095: check[11] = 1; break; case 2047: check[10] = 1; break; case 1023: check[9] = 1; break; case 511: check[8] = 1; break; case 255: check[7] = 1; break; case 127: check[6] = 1; break; case 63: check[5] = 1; break; case 31: check[4] = 1; break; case 15: check[3] = 1; break; case 7: check[2] = 1; break; case 3: check[1] = 1; break; case 1: check[0] = 1; break; } } int ans = 0; for (int bit = 29; bit >= 0; bit--) { if (((1 << bit) & xor_sum) == 0) { continue; } int x = (1 << (bit + 1)) - 1; if (check[bit] > 0) { xor_sum ^= x; ans += 1; } } if (xor_sum != 0) { printf("-1\n"); } else { printf("%d\n", ans); } }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | kenkoooo |
Language | C (Clang 3.8.0) |
Score | 500 |
Code Size | 2204 Byte |
Status | AC |
Exec Time | 14 ms |
Memory | 128 KB |
Compile Error
./Main.c:10:3: warning: implicitly declaring library function 'scanf' with type 'int (const char *restrict, ...)' [-Wimplicit-function-declaration] scanf("%d", &n); ^ ./Main.c:10:3: note: include the header <stdio.h> or explicitly provide a declaration for 'scanf' ./Main.c:126:5: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)' [-Wimplicit-function-declaration] printf("-1\n"); ^ ./Main.c:126:5: note: include the header <stdio.h> or explicitly provide a declaration for 'printf' 2 warnings generated.
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 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 | 128 KB |
003.txt | AC | 6 ms | 128 KB |
004.txt | AC | 6 ms | 128 KB |
005.txt | AC | 4 ms | 128 KB |
006.txt | AC | 13 ms | 128 KB |
007.txt | AC | 13 ms | 128 KB |
008.txt | AC | 13 ms | 128 KB |
009.txt | AC | 13 ms | 128 KB |
010.txt | AC | 14 ms | 128 KB |
011.txt | AC | 14 ms | 128 KB |
012.txt | AC | 13 ms | 128 KB |
013.txt | AC | 13 ms | 128 KB |
014.txt | AC | 13 ms | 128 KB |
015.txt | AC | 13 ms | 128 KB |
016.txt | AC | 13 ms | 128 KB |
017.txt | AC | 13 ms | 128 KB |
018.txt | AC | 13 ms | 128 KB |
019.txt | AC | 13 ms | 128 KB |
020.txt | AC | 13 ms | 128 KB |
021.txt | AC | 2 ms | 128 KB |
022.txt | AC | 2 ms | 128 KB |
023.txt | AC | 12 ms | 128 KB |
example0.txt | AC | 1 ms | 128 KB |
example1.txt | AC | 1 ms | 128 KB |