CF1369F BareLee 题解
:::::success[Hint 1]
我们考虑
对应 Hint 1:
我们设某个
首先我们考虑按照
- 当
s 是偶数时:先手可以每一次都选择直接加一,后手无论选择什么奇偶性都会变化,那么先手一定不会输。 - 当
s 是奇数时:先手一定会操作一次将s 变为偶数,根据上面的分析我们得到后手一定不会输,即先手必败。
那么我们接下来考虑
对于
对于
对于其余情况,事实上等价于先超过
下面我们考虑
我们依旧可以发现,当
那么对于其余的情况,我们发现同样是先超过
对应 Hint 2:
我们考虑怎么将单次的答案统计为全局,这个是比较容易的,将
这样我们就做完了这道题。
时间复杂度为
#include<bits/stdc++.h>
#define inl inline
#define int long long
#define lll __int128
#define fst ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(int i=x;i<=(y);++i)
#define per(i,x,y) for(int i=x;i>=(y);--i)
#define rpr(i,x,y,z) for(int i=x;i<=(y);i+=z)
#define epe(i,x,y,z) for(int i=x;i>=(y);i-=z)
#define repe(i,x,y) for(i=x;i<=(y);++i)
#define endl '\n'
#define INF 1e18
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define lcm(x,y) x/__gcd(x,y)*y
#define ull unsigned long long
#define prr make_pair
#define pii pair<int,int>
#define gt(s) getline(cin,s)
#define at(x,y) for(const auto &x:y)
#define ff fflush(stdout)
#define mt(x,y) memset(x,y,sizeof(x))
#define idg isdigit
#define fp(s) string ssss=s;freopen((ssss+".in").c_str(),"r",stdin);freopen((ssss+\
".out").c_str(),"w",stdout);
#define sstr stringstream
#define all(x) x.begin(),x.end()
#define mcy(a,b) memcpy(a,b,sizeof(b))
#define ui unsigned
#define si signed
#define eb emplace_back
#define pff(x) ((x)*(x))
#define eush emplace
#define double long double
#define pdi pair<double,int>
#ifdef __unix__
#define gc getchar_unlocked
#else
#define gc _getchar_nolock
#endif
#ifdef __unix__
#define pc putchar_unlocked
#else
#define pc _putchar_nolock
#endif
using namespace std;
const int N=1e5+5;
int a[N],b[N];
inl bool checkw(int x,int y){
if(y&1) return !(x&1);
if(x<<1>y) return x&1;
if(x<<2>y) return 1;
return checkw(x,y>>2);
}
inl bool checkl(int x,int y){
if(x<<1>y) return 1;
return checkw(x,y>>1);
}
si main(){
fst;
int n;
bool answ=0,ansl=1;
cin>>n;
rep(i,1,n) cin>>a[i]>>b[i];
per(i,n,1){
bool visw=checkw(a[i],b[i]),visl=checkl(a[i],b[i]);
answ=visl&&answ||visw&&!answ;
ansl=visl&&ansl||visw&&!ansl;
}
cout<<answ<<' '<<ansl<<endl;
return 0;
}
:::::