Submission #4982249


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

ll two[33];
ll a[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll res = 0;
    rep(i,n){
        cin >> a[i];
        res ^= a[i];
    }
    int id = 0;
    two[id] = 1;
    while(res){
        two[id+1] = two[id] * 2;
        res /= 2;
        id++;
    }
    int sm = 0;
    rep(i,id){
        ll cri = 0;
        rep(j,n){
            cri ^= a[j];
        }
        if(cri>>(id-i-1)&1LL){
            bool flag = false;
            rep(j,n){
                if(a[j] == two[id-1-i]){
                    flag = true;
                    a[j]--;
                    sm++;
                    break;
                }
            }
            if(!flag){
                cout << "-1\n";
                return 0;
            }
        }
    }
    cout << sm << "\n";
    return 0;
}

Submission Info

Submission Time
Task C - Cheating Nim
User kopricky
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2498 Byte
Status WA
Exec Time 12 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 13
WA × 13
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 WA 1 ms 256 KB
001.txt AC 1 ms 256 KB
002.txt AC 11 ms 1024 KB
003.txt AC 6 ms 768 KB
004.txt AC 5 ms 640 KB
005.txt AC 4 ms 512 KB
006.txt WA 12 ms 1024 KB
007.txt WA 11 ms 1024 KB
008.txt WA 12 ms 1024 KB
009.txt WA 12 ms 1024 KB
010.txt WA 12 ms 1024 KB
011.txt WA 12 ms 1024 KB
012.txt WA 12 ms 1024 KB
013.txt WA 12 ms 1024 KB
014.txt WA 12 ms 1024 KB
015.txt WA 12 ms 1024 KB
016.txt AC 12 ms 1024 KB
017.txt AC 12 ms 1024 KB
018.txt WA 12 ms 1024 KB
019.txt WA 12 ms 1024 KB
020.txt AC 12 ms 1024 KB
021.txt AC 2 ms 384 KB
022.txt AC 2 ms 384 KB
023.txt AC 11 ms 1024 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB