Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In the name of GOD
- #include <iostream>
- #include <algorithm>
- #include <fstream>
- #include <vector>
- #include <deque>
- #include <assert.h>
- #include <queue>
- #include <stack>
- #include <set>
- #include <map>
- #include <tuple>
- #include <stdio.h>
- #include <string.h>
- #include <utility>
- #include <math.h>
- using namespace std;
- inline int in(){int32_t x ; scanf("%d",&x) ; return x ; }
- inline string get(){char ch[1000010] ; scanf("%s",ch) ; return ch;}
- const int MAX_LG = 21;
- //#define int long long
- #define endl "\n"
- #define mp make_pair
- typedef pair<int , int > pii;
- typedef long double ld;
- typedef unsigned long long ull;
- typedef long long ll;
- const int maxn = 3e3 + 10;
- const int INF = 1e9;
- const int SQ = 317;
- const int mod = 10499;
- bool have[maxn];
- class Roxor
- {
- public:
- map<int,bool> Map;
- bool win(int mask , int n)
- {
- if (Map.count(mask)) return Map[mask];
- bool res = false;
- for (int i = 0 ; i < n - 1 ; i ++)
- {
- if ((mask & (1 << i) )== 0 ) continue;
- for (int j = i + 1 ; j < n ; j ++)
- {
- for (int k = j ; k < n ; k ++)
- {
- res |= !win(mask ^ (1 << i) ^ (1 << j) ^ (1 << k) , n);
- }
- }
- }
- return Map[mask] = res;
- }
- vector <int> play(vector <int> piles)
- {
- int n = (int)piles.size();
- for (int i = 0 ; i < n ; i ++)have[i] = bool(piles[i]) , piles[i] %= 2;
- int mask = 0;
- for (int i = 0 ; i < n ; i ++)
- mask += (1 << i)*piles[i];
- vector<int> res = {};
- for (int i = 0 ; i < n - 1 ; i ++)
- {
- if (have[i])
- for (int j = i + 1 ; j < n ; j ++)
- {
- for (int k = j ; k < n ; k ++)
- {
- if (!win(mask ^ (1 << i) ^ (1 << j) ^ (1 << k) , n ))
- {
- res.push_back(i);
- res.push_back(j);
- res.push_back(k);
- return res;
- }
- }
- }
- }
- return res;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement