Submission #3728757
Source Code Expand
#include <algorithm> #include <iostream> #include <vector> #include <math.h> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <iomanip> #include <numeric> #include <tuple> #include <bitset> #include <complex> #include <unistd.h> #include <cassert> #include <cctype> #include <random> #define _USE_MATH_DEFINES #define _GLIBCXX_DEBUG using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> plglg; typedef pair<double, ll> pdlg; typedef tuple<int, int, int> tiii; typedef tuple<ll, ll, ll> tlglglg; typedef tuple<double, double, double> tddd; typedef complex<double> xy_t; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775807; int iinf = intmax / 8; ll inf = llmax / 8; double eps = 1e-11; int main() { ll N; cin >> N; ll a[N]; ll keta[32]; fill(keta, keta + 32, 0); ll num = 0; for (int i = 0; i < N; i++) { cin >> a[i]; for (int j = 0; j < 32; j++) { if (a[i] & (1 << j)) { keta[j]++; break; } } num = num ^ a[i]; } //cout << num << endl; ll ans = 0; bool ok = true; for (int i = 31; i >= 0; i--) { if ((num & ((ll)1 << i)) > 0 && keta[i] == 0) { ok = false; break; } if (num & (1 << i)) { //cout << i << endl; ans++; for (int j = i; j >= 0; j--) { num = num ^ ((ll)1 << j); } } } if (ok) { cout << ans << endl; } else { cout << -1 << endl; } }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | NMLibrary |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1860 Byte |
Status | AC |
Exec Time | 44 ms |
Memory | 1024 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 | 44 ms | 1024 KB |
003.txt | AC | 14 ms | 768 KB |
004.txt | AC | 16 ms | 640 KB |
005.txt | AC | 13 ms | 512 KB |
006.txt | AC | 42 ms | 1024 KB |
007.txt | AC | 42 ms | 1024 KB |
008.txt | AC | 42 ms | 1024 KB |
009.txt | AC | 42 ms | 1024 KB |
010.txt | AC | 43 ms | 1024 KB |
011.txt | AC | 42 ms | 1024 KB |
012.txt | AC | 43 ms | 1024 KB |
013.txt | AC | 42 ms | 1024 KB |
014.txt | AC | 42 ms | 1024 KB |
015.txt | AC | 42 ms | 1024 KB |
016.txt | AC | 43 ms | 1024 KB |
017.txt | AC | 42 ms | 1024 KB |
018.txt | AC | 43 ms | 1024 KB |
019.txt | AC | 42 ms | 1024 KB |
020.txt | AC | 42 ms | 1024 KB |
021.txt | AC | 5 ms | 256 KB |
022.txt | AC | 5 ms | 256 KB |
023.txt | AC | 42 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |