CF1063C.Dwarves, Hats and Extrasensory Abilities
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an interactive problem.
In good old times dwarves tried to develop extrasensory abilities:
- Exactly n dwarves entered completely dark cave.
- Each dwarf received a hat — white or black. While in cave, none of the dwarves was able to see either his own hat or hats of other Dwarves.
- Dwarves went out of the cave to the meadow and sat at an arbitrary place one after the other. When a dwarf leaves the cave, he sees the colors of all hats of all dwarves that are seating on the meadow (i.e. left the cave before him). However, he is not able to see the color of his own hat and none of the dwarves can give him this information.
- The task for dwarves was to got diverged into two parts — one with dwarves with white hats and one with black hats.
After many centuries, dwarves finally managed to select the right place on the meadow without error. Will you be able to repeat their success?
You are asked to successively name n different integer points on the plane. After naming each new point you will be given its color — black or white. Your task is to ensure that the named points can be split by a line in such a way that all points of one color lie on the same side from the line and points of different colors lie on different sides. Moreover, no points can belong to the line. Also, you need to report any such line at the end of the process.
In this problem, the interactor is adaptive — the colors of the points in the tests are not fixed beforehand and the jury program can select them arbitrarily, in particular, depending on your program output.
Interaction
The first line of the standard input stream contains an integer n (1 ≤ n ≤ 30) — the number of points your program should name.
Then n times your program must print two integer coordinates x and y (0 ≤ x ≤ 109, 0 ≤ y ≤ 109). All points you print must be distinct.
In response to each coordinate pair your program will receive the string "black", if the point is black, or "white", if the point is white.
When all n points are processed, you need to print four integers _x_1, _y_1, _x_2 and _y_2 (0 ≤ _x_1, _y_1 ≤ 109, 0 ≤ _x_2, _y_2 ≤ 109) — coordinates of points (_x_1, _y_1) and (_x_2, _y_2), which form a line, which separates n points into black and white. Points (_x_1, _y_1) and (_x_2, _y_2) should not coincide.
Hacks
To hack solution use the following format. The first line must contain word "hack", the second line should contain the number n and the last line should contain the sequence of 0 and 1 — colors of points, which will be reported to the solution. Unlike the jury tests, colors of points in hacks are always fixed in advance. Of course, the hacked solution wouldn't be able to get the information about the colors in advance.
For example, the hack corresponding to sample test will look like this:
hack
5
0 0 1 1 0
这是一个交互式问题。
在古老的年代,矮人们曾尝试开发超感官能力:
- 恰好有 n 个矮人进入了一个完全黑暗的洞穴。
- 每个矮人都获得了一顶帽子——白色或黑色。在洞穴内,没有任何一个矮人能看见自己或其余矮人的帽子颜色。
- 矮人们依次走出洞穴,来到草地上,并随意就座(一人接一人)。当某个矮人离开洞穴时,他能看到所有已坐在草地上的矮人(即比他早离开洞穴者)所戴帽子的颜色。但他无法看到自己帽子的颜色,且其他矮人也不能向他透露该信息。
- 矮人们的任务是将自己分成两组:一组全是戴白帽的矮人,另一组全是戴黑帽的矮人。
经过多个世纪的努力,矮人们终于成功地在草地上选出了正确的分组位置,且从未出错。你能否重现他们的成功?
你需要依次在平面上指定 n 个互不相同的整数坐标点。每指定一个新的点后,你会立即获知该点的颜色——“black”(黑色)或“white”(白色)。你的任务是确保:所有已指定的点能够被某条直线严格分离,即同色点全部位于该直线的同一侧,异色点则分别位于直线两侧;此外,不允许有任何点恰好落在该直线上。最后,你还须输出这样一条直线(以直线上两个不同整数点 (x1,y1) 和 (x2,y2) 的坐标形式给出)。
本题的交互器是自适应的——测试用例中各点的颜色并非预先固定,评测程序可任意选择(甚至可根据你的程序输出动态决定)。
交互流程
标准输入流的第一行包含一个整数 n(1≤n≤30),表示你的程序需指定的点的数量。
随后,你的程序需重复 n 次,每次输出两个整数坐标 x 和 y(0≤x≤109, 0≤y≤109)。你输出的所有点必须互不相同。
对于你输出的每个坐标对,程序将收到字符串 "black"(若该点为黑色)或 "white"(若该点为白色)作为响应。
当全部 n 个点均处理完毕后,你需要输出四个整数 x1, y1, x2, y2(0≤x1,y1≤109, 0≤x2,y2≤109),表示直线上的两点 (x1,y1) 和 (x2,y2),该直线可将 n 个点按颜色严格分离。注意:(x1,y1) 与 (x2,y2) 必须是两个不同的点。
Hack 方法
要对某个解法进行 hack,请使用如下格式:第一行必须为单词 "hack";第二行为整数 n;第三行为一串由 0 和 1 组成的序列(空格分隔),表示将反馈给被 hack 解法的各点颜色(0 表示 white,1 表示 black)。与正式评测用例不同,hack 中的点颜色总是预先固定的。当然,被 hack 的解法无法提前获知这些颜色信息。
例如,对应样例测试的 hack 输入如下:
hack
5
0 0 1 1 0
输入输出样例
输入#1
5 black black white white black
输出#1
0 0 3 1 2 3 4 4 0 2 1 3 4 1
说明/提示
In the sample input and output values are aligned only for simplicity of interpreting them chronologically. In real interaction no "extra" line breaks should appear.
The following picture illustrates the first test.

在样例输入和输出中,数值仅为了便于按时间顺序理解而对齐。在实际交互中,不应出现任何“额外”的换行。
下图展示了第一个测试用例。

输入解题思路,AI测评打分。不知道怎么写?