Submission #1000579


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  int x = 0;
  rep(i,n) scanf("%d",&a[i]), x ^= a[i];
  vi b;
  rep(i,n) b.pb(pcnt(a[i]^(a[i]-1)));
  sort(rng(b));
  reverse(rng(b));
  int ans = 0;
  rep(i,n) {
    int s = b[i];
    if (x >= (1<<s>>1)) {
      ++ans;
      x ^= (1<<s)-1;
    }
  }
  if (x) ans = -1;
  cout<<ans<<endl;
  return 0;
}





























Submission Info

Submission Time
Task C - Cheating Nim
User snuke
Language C++14 (GCC 5.4.1)
Score 500
Code Size 2514 Byte
Status AC
Exec Time 18 ms
Memory 1276 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:66:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
./Main.cpp:69:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   rep(i,n) scanf("%d",&a[i]), x ^= a[i];
                                        ^

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 2 ms 256 KB
001.txt AC 2 ms 256 KB
002.txt AC 17 ms 1276 KB
003.txt AC 9 ms 896 KB
004.txt AC 9 ms 896 KB
005.txt AC 7 ms 640 KB
006.txt AC 18 ms 1276 KB
007.txt AC 18 ms 1276 KB
008.txt AC 18 ms 1276 KB
009.txt AC 18 ms 1276 KB
010.txt AC 18 ms 1276 KB
011.txt AC 18 ms 1276 KB
012.txt AC 18 ms 1276 KB
013.txt AC 18 ms 1276 KB
014.txt AC 18 ms 1276 KB
015.txt AC 18 ms 1276 KB
016.txt AC 18 ms 1276 KB
017.txt AC 18 ms 1276 KB
018.txt AC 18 ms 1276 KB
019.txt AC 18 ms 1276 KB
020.txt AC 18 ms 1276 KB
021.txt AC 4 ms 384 KB
022.txt AC 4 ms 384 KB
023.txt AC 16 ms 1276 KB
example0.txt AC 2 ms 256 KB
example1.txt AC 2 ms 256 KB