CF1934D2 题解
sunkuangzheng · · 题解
- 有一个整数
n ,你和交互库轮流进行拆分。一次拆分指的是一方选择两个整数p_1,p_2 满足0 < p_1,p_2 < n,p_1 \oplus p_2 = n ,对方从p_1,p_2 中选择一个替换掉n ,然后对方继续拆分。当一方无法拆分时视为失败。- 你可以选择先手或者后手和交互库博弈。
记
猜测结论:
然后模拟上述过程构造方案即可。注意到我们只会进行拆分偶数操作,我们每次可以直接拆成
/**
* author: sunkuangzheng
* created: 02.03.2024 12:24:54
**/
#include<bits/stdc++.h>
#ifdef DEBUG_LOCAL
#include <mydebug/debug.h>
#endif
using ll = long long;
const int N = 5e5+5;
using namespace std;
int T; ll n,p1,p2;
void los(){
cin >> n;
auto ck = [&](ll x){return __builtin_popcountll(x) & 1;};
auto lb = [&](ll x){return 1ll << (63 - __builtin_clzll(x));};
cout << (ck(n) ? "Second" : "First") << endl;
if(!ck(n)) cout << lb(n) << " " << (n ^ lb(n)) << endl;
while(1){
cin >> p1 >> p2; if(p1 == -1) assert(0);
if(!p1 && !p2) return ;
if(ck(p1)) cout << lb(p2) << " " << (p2 ^ lb(p2)) << endl;
else cout << lb(p1) << " " << (p1 ^ lb(p1)) << endl;
}
}int main(){
ios::sync_with_stdio(0),cin.tie(0);
for(cin >> T;T --;) los();
}
请注意,拆成
UPD:拆成