CF1064 e-dwarves, Hats and extrasensory abilities

Source: Internet
Author: User

Test instructions

The interaction problem should have been carried out on the plane.
In fact, a straight line can be, in fact, to be more complex on the plane.

Solution

Assuming that the \ (l\) dot is a black point, \ (r\) is the white dot, then place the next point at \ (l + r/2\) , then recursively.

Code
#include <ctype.h> #include <stdio.h> #include <string> #include <iostream> #include <    algorithm>using namespace Std;const int N = 39;struct Node {int color, position; BOOL operator < (const Node &x) Const {return color = = X.color? position < X.position:color < x.co    Lor    }} p[n];const int XXX = 4323;bool Check (int position, int now) {string S;    P[now].position = position;    printf ("%d%d\n", XXX, position);    Fflush (stdout);    Cin >> S;    if (s = = "White") return p[now].color = 0; else return p[now].color = 1;}    int main () {int n;    scanf ("%d", &n);    int L = 1, R = 1e9, mid;        for (int i = 1; I <= n; i + = 1) {mid = L + R >> 1;        if (Check (Mid, i)) R = Mid;    else L = mid;    } int res = 0;    for (int i = 1; i < n; i + = 1) std:: Swap (P[i], p[i + 1]);    Std::sort (p + 1, p + 1 + N); for (int i = 2; I <= n; i + = 1) if (p[i].color! = P[i-1].color) {            res = p[i-1].position + 1;          Break    } if (res) printf ("%d%d%d%d\n", XXX-1, Res-1, XXX + 1, res), fflush (stdout);    else printf ("%d%d%d\n", XXX-1, Res, XXX + 1, res), fflush (stdout); return 0;}

CF1064 e-dwarves, Hats and extrasensory abilities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.