Submission #3916352
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define i_7 (ll)(1E9+7) #define i_5 (ll)(1E9+5) ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair<int,int> i_i; typedef pair<ll,ll> l_l; ll inf=(ll)1E12; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(a<b)return b;else return a;} ll min(ll a,ll b){if(a>b)return b;else return a;} void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]); void Min(ll * pos,ll val){*pos=min(*pos,val);} void Add(ll * pos,ll val){*pos=mod(*pos+val);} const long double EPS=1E-8; //////////////////////////////////////// ll f(ll n){ ll res=0; while(n>=1){ if(n%2==0){ n/=2; res++; }else break; } return res; } int main(){ ll n;cin>>n; ll a[n];rep(i,0,n-1)cin>>a[i]; bool changed[n];memset(changed,false,sizeof(changed)); ll p[n]; rep(i,0,n-1){ p[i]=f(a[i]); } ll ans=0; for(ll i=40;i>=0;i--){ ll c=0; ll num=-1; rep(j,0,n-1){ if(changed[j]==false&&(a[j]>>i)&1)c++; if(p[j]==i)num=j; } if((c+ans)%2==1){ if(num==-1){ cout<<-1;return 0; } ans++; changed[num]=true; } } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | sugarrr |
Language | C++14 (GCC 5.4.1) |
Score | 500 |
Code Size | 1445 Byte |
Status | AC |
Exec Time | 50 ms |
Memory | 1920 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 | 50 ms | 1920 KB |
003.txt | AC | 18 ms | 1280 KB |
004.txt | AC | 18 ms | 1024 KB |
005.txt | AC | 14 ms | 768 KB |
006.txt | AC | 48 ms | 1920 KB |
007.txt | AC | 48 ms | 1920 KB |
008.txt | AC | 48 ms | 1920 KB |
009.txt | AC | 48 ms | 1920 KB |
010.txt | AC | 48 ms | 1920 KB |
011.txt | AC | 48 ms | 1920 KB |
012.txt | AC | 48 ms | 1920 KB |
013.txt | AC | 48 ms | 1920 KB |
014.txt | AC | 48 ms | 1920 KB |
015.txt | AC | 48 ms | 1920 KB |
016.txt | AC | 48 ms | 1920 KB |
017.txt | AC | 47 ms | 1920 KB |
018.txt | AC | 48 ms | 1920 KB |
019.txt | AC | 48 ms | 1920 KB |
020.txt | AC | 48 ms | 1920 KB |
021.txt | AC | 5 ms | 384 KB |
022.txt | AC | 5 ms | 384 KB |
023.txt | AC | 44 ms | 1920 KB |
example0.txt | AC | 1 ms | 256 KB |
example1.txt | AC | 1 ms | 256 KB |