Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define nl "\n"
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define RV return void
- #define sz(x) int(x.size())
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define fixed(n) fixed << setprecision(n)
- #define cin(v) for(auto&x:v) cin >> x;
- #define cout(v) for(auto&x:v) cout << x << " ";
- void files(){
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- //
- int n , sum=0;
- vector < int > v;
- vector < vector < vector < int > > > dp;
- int rec(int l , int r , int xr , bool turn){
- if(l > r or l > n-1 or r < 0){
- if(xr > (sum ^ xr)) return 1;
- else if((sum ^ xr) > xr) return 0;
- else return -1;
- }
- int & ret=dp[l][r][xr];
- if(~ret)
- return ret;
- if(!turn){
- ret =-1e9;
- ret = max(ret , rec(l+1 ,r , xr ^ (v[l]), 1-turn));
- ret = max(ret , rec(l ,r -1, xr ^ (v[r]), 1-turn));
- }else{
- ret = 1e9;
- ret = min(ret , rec(l+1 ,r , xr , 1-turn));
- ret = min(ret , rec(l ,r -1, xr , 1-turn));
- }
- return ret;
- }
- void solve(){
- cin >> n ;
- v.assign(n,0);
- int mx =0;
- for(int i=0 ; i <n ; i++){
- cin >> v[i];
- sum ^= v[i];
- }
- // cout << rec(0 , n-1 , 0 , 0) << nl;
- dp.assign(n+1 , vector < vector <int> > (n+1 , vector < int > (1025 , -1)));
- int ret = rec(0 , n-1 , 0 , 0) ;
- if(ret == 1)
- cout <<"Toty";
- else if(ret ==0)
- cout<<"Boty";
- else
- cout <<"Toty-Boty";
- }
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // files();
- int testCase=1;
- // cin >> testCase ;
- for(int i=1 ; i <= testCase ; i++){
- // cout << "Case "<< i <<": " << nl;
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement