Submission #3434920


Source Code Expand

#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll MOD = (ll)1e9 + 7; // 998244353
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;


void YN(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Yn(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void yn(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}



int main() {
	ll N; cin >> N;
	VL a(N); REP(i, N) cin >> a[i];
	sort(ALL(a));
	VL bit(30, 0);
	VB lst(30, false);
	for (int j = 0; j < N; ++j) {
		for (int i = 0; i < 30; ++i) {
			if ((a[j]) & (1 << i)) {
				lst[i] = true;
				break;
			}
		}
	}
	for (auto b : a) for (int i = 29; 0 <= i; --i) bit[i]+= (bool)((b) & (1 << i));
	int ans = 0;
	for (int i = 29; 0 <= i; --i) {
		if (lst[i] & (bit[i] % 2)) {
			bit[i]--;
			for (int j = i - 1; 0 <= j; --j) ++bit[j];
			ans++;
		}
	}
	for (int i = 0; i < 30; ++i) if (bit[i] % 2) ans = -1;
	cout << ans << endl;
		
	return 0;
}

Submission Info

Submission Time
Task C - Cheating Nim
User ningenMe
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2526 Byte
Status AC
Exec Time 52 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 26
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 50 ms 1024 KB
003.txt AC 19 ms 768 KB
004.txt AC 21 ms 640 KB
005.txt AC 16 ms 512 KB
006.txt AC 52 ms 1024 KB
007.txt AC 51 ms 1024 KB
008.txt AC 52 ms 1024 KB
009.txt AC 51 ms 1024 KB
010.txt AC 51 ms 1024 KB
011.txt AC 52 ms 1024 KB
012.txt AC 51 ms 1024 KB
013.txt AC 51 ms 1024 KB
014.txt AC 52 ms 1024 KB
015.txt AC 52 ms 1024 KB
016.txt AC 52 ms 1024 KB
017.txt AC 52 ms 1024 KB
018.txt AC 52 ms 1024 KB
019.txt AC 52 ms 1024 KB
020.txt AC 52 ms 1024 KB
021.txt AC 6 ms 256 KB
022.txt AC 6 ms 256 KB
023.txt AC 50 ms 1024 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB