Submission #3729438
Source Code Expand
#include<iostream> #include<vector> #include<algorithm> #include<set> #include<map> #include<unordered_map> #include<queue> #include<iomanip> #include<math.h> #include<bitset> #include<cassert> #include<random> #include<time.h> #include<functional> using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;} #define ALL(v) v.begin(),v.end() #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end()); #define pb push_back /* --------------------------------------- */ int main() { cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; ll exor = 0; REP(i,n) exor ^= a[i]; vector<bool> cnt(30, false); // 最下位 1 bit が i REP(i, n) { bitset<30> bi(a[i]); REP(j, 30) if(bi[j]) { cnt[j] = true; break; } } ll ans = 0; bitset<30> bi(exor); for(ll i = 29; i >= 0; i--) { if(bi[i]) { if(!cnt[i]) { cout << -1 << endl; return 0; } ans++; for(ll j = i; j >= 0; j--) bi[j] = bi[j] ^ 1; } } cout << ans << endl; return 0; } /* --------------------------------------- */
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | gazelle |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1386 Byte |
Status | AC |
Exec Time | 13 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 | 12 ms | 1024 KB |
003.txt | AC | 6 ms | 768 KB |
004.txt | AC | 6 ms | 640 KB |
005.txt | AC | 4 ms | 512 KB |
006.txt | AC | 13 ms | 1024 KB |
007.txt | AC | 13 ms | 1024 KB |
008.txt | AC | 13 ms | 1024 KB |
009.txt | AC | 13 ms | 1024 KB |
010.txt | AC | 13 ms | 1024 KB |
011.txt | AC | 13 ms | 1024 KB |
012.txt | AC | 13 ms | 1024 KB |
013.txt | AC | 13 ms | 1024 KB |
014.txt | AC | 13 ms | 1024 KB |
015.txt | AC | 13 ms | 1024 KB |
016.txt | AC | 13 ms | 1024 KB |
017.txt | AC | 13 ms | 1024 KB |
018.txt | AC | 13 ms | 1024 KB |
019.txt | AC | 13 ms | 1024 KB |
020.txt | AC | 13 ms | 1024 KB |
021.txt | AC | 2 ms | 384 KB |
022.txt | AC | 2 ms | 384 KB |
023.txt | AC | 13 ms | 1024 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |