Submission #1833583
Source Code Expand
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "string" #include "map" #include "iomanip" #include "cmath" using namespace std; const long long int MOD = 1000000007; long long int N, M, K, H, W, L, R; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; vector<long long int>v(N); for (int i = 0; i < N; i++) { cin >> v[i]; M ^= v[i]; } for (int i = 30; i >=0; i--) { if (M >> i & 1) { bool flag = false; for (int j = 0; j < N; j++) { if (v[j] % (int)pow(2, i) == 0 && v[j] % (int)pow(2, i + 1)) { flag = true; } } if (!flag) { cout << "-1\n"; return 0; } M ^= (int)pow(2, i); M ^= (int)(pow(2, i) - 1); K++; } } if (!M) { cout << K << endl; } else { cout << "-1\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | olphe |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 928 Byte |
Status | AC |
Exec Time | 226 ms |
Memory | 1152 KB |
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 | 256 KB |
001.txt | AC | 1 ms | 256 KB |
002.txt | AC | 11 ms | 1024 KB |
003.txt | AC | 25 ms | 768 KB |
004.txt | AC | 9 ms | 640 KB |
005.txt | AC | 6 ms | 512 KB |
006.txt | AC | 217 ms | 1024 KB |
007.txt | AC | 188 ms | 1024 KB |
008.txt | AC | 223 ms | 1024 KB |
009.txt | AC | 226 ms | 1024 KB |
010.txt | AC | 149 ms | 1024 KB |
011.txt | AC | 145 ms | 1024 KB |
012.txt | AC | 167 ms | 1024 KB |
013.txt | AC | 163 ms | 1024 KB |
014.txt | AC | 160 ms | 1024 KB |
015.txt | AC | 178 ms | 1024 KB |
016.txt | AC | 158 ms | 1024 KB |
017.txt | AC | 91 ms | 1024 KB |
018.txt | AC | 192 ms | 1152 KB |
019.txt | AC | 165 ms | 1024 KB |
020.txt | AC | 184 ms | 1024 KB |
021.txt | AC | 3 ms | 384 KB |
022.txt | AC | 4 ms | 384 KB |
023.txt | AC | 19 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |