标签:ace turn cpp == als lse string com lin
冷冷淡淡,平平常常就好。
这题好水呀
其实还是考你的观察敏锐度的。有时候好好看数据 \(\log 10^{10} =29\)
然后,二分这个位置,开始讨论黑白?
然后注意细节
突然爱上 c++ 读入
#include <iostream>
#include <string>
using namespace std;
const int ee = 1 << 29;
int white_max, black_min, black_max, white_min, x, n;
string str;
void ask() {
cout << x << " " << x <<endl;
cin >> str;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
ask(); x = ee / 2;
if(str == "black") {
black_max = 1; white_min = ee;
for(int i = 2; i <= n ; ++i) {
ask();
if(str == "black") black_max = x;
else white_min = x;
if(i != n) {
if(str == "black") x = (black_max + white_min) / 2;
else x = (white_min + black_max) / 2;
}
}
if(str == "black") cout << x + 1 << " " << x << " " << x << " " << x + 1;
else cout << x - 1 << " " << x << " " << x << " " << x - 1;
}
else {
white_max = 1; black_min = ee;
for(int i = 2; i <= n; ++i){
ask();
if(str == "black") black_min = x;
else white_max = x;
if(i != n) {
if(str == "black") x = (white_max + black_min) / 2;
else x = (black_min + white_max) / 2;
}
}
if(str == "white") cout << x + 1 << " " << x << " " << x << " " << x + 1;
else cout << x - 1 << " " << x << " " << x << " " << x - 1;
}
return 0;
}
世上一切,往往不如你所愿
标签:ace turn cpp == als lse string com lin
原文地址:https://www.cnblogs.com/zhltao/p/12516693.html