CF1063D

Posted zhltao

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CF1063D相关的知识,希望对你有一定的参考价值。

CF1063D

冷冷淡淡,平平常常就好。

正文

这题好水呀

其实还是考你的观察敏锐度的。有时候好好看数据 (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;
}

世上一切,往往不如你所愿

以上是关于CF1063D的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces 1063D Candies for Children

Codeforces1063D Candies for Children 分类讨论暴力

如何从后台弹出片段

cf 模拟

CF1435 游记

无法解析符号 c882c94be45fff9d16a1cf845fc16ec5