• 微信公众号：美女很有趣。 工作之余，放松一下，关注即送10G+美女照片！

# Codeforces 1369F. BareLee 题解

2周前 (04-29) 8次浏览

## Codeforc++es 1369F. BareLee

#### 题意

(win(e,s))表示能否先手获胜。

(e/4 < s <= e/2)时，先手必胜。

(s <= e/4)时，答案为(win(e/4,s))。原因是先操作使得(e/4 < s <= e/2)的人必输。

(lose(e,s))表示能否先手失败。

``````#include<bits/stdc++.h>
#define int long long
#define N 1000015
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define VI vector<int>
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
int win(int e,int s){
if(s == e) return 0;
if(s+1 == e) return 1;
if(e&1) return !(s&1);
if(s <= e/4) return win(e/4,s);
if(s <= e/2) return 1;
return (e-s)&1;
}
int lose(int e,int s){
if((s<<1) > e) return 1;
return win(e/2,s);
}
int n,a,b,w[N],l[N];
signed main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
scanf("%lld",&n);
rep(i,1,n) {
scanf("%lld%lld",&a,&b);
w[i] = win(b,a); l[i] = lose(b,a);
}
a = w[n];
per(i,1,n-1){
if(a) {if(!l[i]) a ^= 1;}
else if(w[i]) a ^= 1;
}
printf("%lld ",a);
a = l[n];
per(i,1,n-1){
if(a){if(!l[i]) a ^= 1;}
else if(w[i]) a ^= 1;
}
printf("%lldn",a);
return 0;
}
``````