Submission #1247830
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for (ll i=(a);i<(b);i++) #define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--) #define REP(i,n) for (ll i=0;i<(n);i++) #define RREP(i,n) for (ll i=(n)-1;i>=0;i--) #define debug(x) cout<<#x<<": "<<x<<endl #define pb push_back #define ALL(a) (a).begin(),(a).end() const ll linf = 1e18; const int inf = 1e9; const double eps = 1e-12; const double pi = acos(-1); template<typename T> istream& operator>>(istream& is, vector<T>& vec) { EACH(x,vec) is >> x; return is; } template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { REP(i,vec.size()) { if (i) os << " "; os << vec[i]; } return os; } template<typename T> ostream& operator<<(ostream& os, const vector< vector<T> >& vec) { REP(i,vec.size()) { if (i) os << endl; os << vec[i]; } return os; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector<ll> v(n); cin >> v; ll g = 0; REP(i, n) g ^= v[i]; ll gb = g; while ( __builtin_popcount(gb) > 1 ) { gb ^= gb & -gb; } ll ans = -1; REP(i, n) { if (v[i] & gb) { ll a = v[i] - (v[i] ^ g); if (a <= n) { ans = a; break; } } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1501 Byte |
Status | WA |
Exec Time | 12 ms |
Memory | 1024 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 11 ms | 1024 KB |
003.txt | WA | 5 ms | 768 KB |
004.txt | AC | 5 ms | 640 KB |
005.txt | AC | 4 ms | 512 KB |
006.txt | WA | 11 ms | 1024 KB |
007.txt | WA | 11 ms | 1024 KB |
008.txt | WA | 11 ms | 1024 KB |
009.txt | WA | 11 ms | 1024 KB |
010.txt | WA | 11 ms | 1024 KB |
011.txt | WA | 11 ms | 1024 KB |
012.txt | WA | 11 ms | 1024 KB |
013.txt | WA | 11 ms | 1024 KB |
014.txt | WA | 11 ms | 1024 KB |
015.txt | WA | 11 ms | 1024 KB |
016.txt | AC | 11 ms | 1024 KB |
017.txt | AC | 11 ms | 1024 KB |
018.txt | WA | 11 ms | 1024 KB |
019.txt | WA | 11 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 |