码迷,mamicode.com
首页 > 其他好文 > 详细

CF1063D

时间:2020-03-18 14:03:34      阅读:57      评论:0      收藏:0      [点我收藏+]

标签:ace   turn   cpp   ==   als   lse   string   com   lin   

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

标签:ace   turn   cpp   ==   als   lse   string   com   lin   

原文地址:https://www.cnblogs.com/zhltao/p/12516693.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!