Submission #4268568
Source Code Expand
#include <bits/stdc++.h> #include <unordered_map> typedef long long ll; #define rep(i,m,n) for(ll i = (m); i < (n); i++) #define rrep(i,m,n) for(ll i = (m); i >= (n); i--) #define print(x) cout << (x) << endl; #define print2(x,y) cout << (x) << " " << (y) << endl; #define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];} #define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl; #define INF (1e18) using namespace std; const ll MOD = 1e9 + 7; typedef pair<ll, ll> lpair; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N; ll a[100010]; cin >> N; rep(i,0,N) cin >> a[i]; ll is_used[100010] = {}; bool ok = true; rrep(bit,31,0){ ll cnt = 0; rep(i,0,N){ if((a[i]>>bit) & 1) cnt++; } if(cnt % 2 == 0) continue; // print(bit); bool flg = true; rep(i,0,N){ if(a[i] % (1LL<<(bit+1)) == (1LL<<(bit)) && is_used[i] == 0){ is_used[i] = 1; // print2(bit,i); a[i]--; flg = false; break; } } if(flg){ ok = false; } } if(!ok){ print(-1); }else{ ll ans = 0; rep(i,0,N){ if(is_used[i] == 1) ans++; } print(ans); } //010 //011 //100 //001 //010 //011 }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | yuji9511 |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1539 Byte |
Status | AC |
Exec Time | 17 ms |
Memory | 1792 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 | 2 ms | 1024 KB |
001.txt | AC | 2 ms | 1024 KB |
002.txt | AC | 14 ms | 1792 KB |
003.txt | AC | 7 ms | 1536 KB |
004.txt | AC | 8 ms | 1408 KB |
005.txt | AC | 6 ms | 1280 KB |
006.txt | AC | 14 ms | 1792 KB |
007.txt | AC | 14 ms | 1792 KB |
008.txt | AC | 14 ms | 1792 KB |
009.txt | AC | 14 ms | 1792 KB |
010.txt | AC | 14 ms | 1792 KB |
011.txt | AC | 15 ms | 1792 KB |
012.txt | AC | 14 ms | 1792 KB |
013.txt | AC | 14 ms | 1792 KB |
014.txt | AC | 14 ms | 1792 KB |
015.txt | AC | 14 ms | 1792 KB |
016.txt | AC | 16 ms | 1792 KB |
017.txt | AC | 15 ms | 1792 KB |
018.txt | AC | 14 ms | 1792 KB |
019.txt | AC | 14 ms | 1792 KB |
020.txt | AC | 15 ms | 1792 KB |
021.txt | AC | 3 ms | 1152 KB |
022.txt | AC | 3 ms | 1152 KB |
023.txt | AC | 17 ms | 1792 KB |
example0.txt | AC | 2 ms | 1024 KB |
example1.txt | AC | 2 ms | 1024 KB |