Colder-Hotter

Statements

This is an interactive problem.

Egor and Petr are playing a game called «Colder-Hotter» on a 2D plane. At the beginning of the game Egor thinks of a point with non-negative integer coordinates not exceeding 109. Then Petr tries to guess this point: on the i-th turn he chooses some point with integer coordinates (xi, yi) and tells them to Egor. If this point is closer to the one being guessed than the previous point (xi - 1, yi - 1), then Egor answers "1". Otherwise, and also if this is the first turn of the game, he answers "0".

When there are no more turns left or Petr thinks he has enough information, he stops the game and tells his answer. If the answer is correct Petr is considered to be a winner. As Petr becomes more and more experienced, Egor reduces the number of turns.

The current limit on the number of turns in their game is 500. Petr asks you to write a program that will successfully beat Egor.

Egor is a fair player and does not change the point after the game has started.

Input

The jury program outputs either "1" in case when the current point from player is closer to the one being guessed than the previous point, or "0" when the current point from player is not closer than previous one or there is no previous point.

Output

If a player makes a turn, he must output two integer numbers with a single space character between them — x- and y-coordinates of the pronounced point (0 ≤ x, y ≤ 109). If a player wants to stop the game he must output a character 'A' and then two integer numbers — x- and y-coordinates of the guessed point, and then stop the program.

After each output (one guess or answer) you must print one end of line, flush output stream, and read the answer. See the notes if you do not know how to execute a flush command. If your program receives an EOF (end-of-file) condition on the standard input, it must exit immediately with exit code 0. Failure to comply with this requirement may result in "Time Limit Exceeded" error.

It is guaranteed that the coordinates of the point being guessed are non-negative and do not exceed 109.

Examples

Input
 
0
 
0
 
1
 
0
 
1
 
0
Output
1 1
 
0 0
 
20 20
 
20 20
 
17 239
 
17 240
 
A 17 239

Note

The point being guessed in the sample is (x = 17, y = 239). One of the possible scenarios of the game is shown:

  1. Petr names the point (1, 1) and Egor replies 0, because it is the first turn.
  2. Petr now names the point (0, 0) which is farther from (x = 17, y = 239) than (1, 0), thus Egor replies 0 again.
  3. Next point is (20, 20), and now the reply is 1.
  4. Now Petr names (20, 20) again just to show you that the answer for this case is 0, because the relation "closer" is irreflexive.
  5. Now Petr accidentally names the point (17, 239), but Egor doesn't say that this is the answer: according to the game rules he just says that it's closer to the point being guessed than the previous one.
  6. Egor answers 0 for (17, 240).
  7. Petr decides to try his fortune and names the point (17, 239). Note that he actually hasn't had enough information to be sure, so he is correct accidentally.

To flush the standard output stream, use the following statements:

In C, use fflush(stdout);

In C++, use cout.flush();

In Java, use System.out.flush();

第二道交互题。用有限的次数找到目标坐标点。每次访问一个坐标,都会告诉你相比上一个坐标离目标点近了还是远了。

将横纵坐标分开考虑,先固定纵坐标y(设为0),找到横坐标x,再固定横坐标x,找到纵坐标y。

因为函数图像包含凸凹点,很容易想到三分。

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = ; int main(void)
{
int t,tt,x,y;
int l=,r=,m,mm;
while(){
printf("0 0\n");
fflush(stdout);
scanf("%d",&t);
m=(l+r)/;
mm=(m+r)/;
if(m==mm){
printf("%d 0\n",l);
fflush(stdout);
scanf("%d",&t);
printf("%d 0\n",m);
fflush(stdout);
scanf("%d",&tt);
if(tt==) l=m;
else r=l;
}
else{
printf("%d 0\n",m);
fflush(stdout);
scanf("%d",&t);
printf("%d 0\n",mm);
fflush(stdout);
scanf("%d",&tt);
if(t==&&tt==){
l=m;
}
else{
r=mm;
}
}
if(l+>=r) break;
}
if(l==r){
x=l;
}
else{
printf("0 0\n");
fflush(stdout);
scanf("%d",&t);
printf("%d 0\n",l);
fflush(stdout);
scanf("%d",&t);
printf("%d 0\n",r);
fflush(stdout);
scanf("%d",&tt);
if(t==&&tt==){
x=r;
}
else{
x=l;
}
}
l=;r=;
while(){
printf("%d 0\n",x);
fflush(stdout);
scanf("%d",&t);
m=(l+r)/;
mm=(m+r)/;
if(m==mm){
printf("%d %d\n",x,l);
fflush(stdout);
scanf("%d",&t);
printf("%d %d\n",x,m);
fflush(stdout);
scanf("%d",&tt);
if(tt==) l=m;
else r=l;
}
else{
printf("%d %d\n",x,m);
fflush(stdout);
scanf("%d",&t);
printf("%d %d\n",x,mm);
fflush(stdout);
scanf("%d",&tt);
if(t==&&tt==){
l=m;
}
else{
r=mm;
}
}
if(l+>=r) break;
}
if(l==r){
y=l;
}
else{
printf("%d 0\n",x);
fflush(stdout);
scanf("%d",&t);
printf("%d %d\n",x,l);
fflush(stdout);
scanf("%d",&t);
printf("%d %d\n",x,r);
fflush(stdout);
scanf("%d",&tt);
if(t==&&tt==){
y=r;
}
else{
y=l;
}
}
printf("A %d %d\n",x,y);
fflush(stdout);
return ;
}

Gym - 100792C Colder-Hotter(三分交互)的更多相关文章

  1. Gym 100792C Colder-Hotter (三分)

    题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回1,否则返回0,第一次猜一定返回0,在不超过500次的情况下,猜出正确答案. 析:是一个简单的三分 ...

  2. Gym 101246J Buoys(三分查找)

    http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...

  3. Gym - 101375H MaratonIME gets candies 交互题

    交互题介绍:https://loj.ac/problem/6 题意:输出Q X ,读入><= 来猜数,小于50步猜出就算过样例 题解:根本不需要每次输出要打cout.flush()... ...

  4. Gym - 100851J: Jump(交互+构造+(大胆瞎搞)))

    题意:给定长度为N的01串,现在让你猜这个串,猜的次数要不超过N+500次. 每次你猜一个串,系统会返回N/2,或N,或0.当且当有N/2个位置猜对,N个位置猜对,其他. 思路:因为信息不多,没有关联 ...

  5. github上DQN代码的环境搭建,及运行(Human-Level Control through Deep Reinforcement Learning)conda配置

    最近师弟在做DQN的实验,由于是强化学习方面的东西,正好和我现在的研究方向一样于是我便帮忙跑了跑实验,于是就有了今天的这个内容. 首先在github上进行搜寻,如下图: 发现第一个星数最多,而且远高于 ...

  6. POJ 2540 Hotter Colder --半平面交

    题意: 一个(0,0)到(10,10)的矩形,目标点不定,从(0,0)开始走,如果走到新一点是"Hotter",那么意思是离目标点近了,如果是"Colder“,那么就是远 ...

  7. poj 2540 Hotter Colder 切割多边形

    /* poj 2540 Hotter Colder 切割多边形 用两点的中垂线切割多边形,根据冷热来判断要哪一半 然后输出面积 */ #include <stdio.h> #include ...

  8. POJ 2540 Hotter Colder(半平面交)

    Description The children's game Hotter Colder is played as follows. Player A leaves the room while p ...

  9. 【Gym 100685J】Just Another Disney Problem(交互/排序)

    第一次做交互题. 题意是有n个数(n<1000),你通过问1 a b,后台返回你YES代表a<b,NO代表a>b.要你在10000次询问内给出一个符合的排列.n=1000来说,100 ...

随机推荐

  1. C++对C语言的拓展(4)—— 函数重载

    函数重载(Function Overload):用同一个函数名定义不同的函数,当函数名和不同的参数搭配时函数的含义不同. 1.重载规则 (1)函数名相同: (2)参数个数不同,参数的类型不同,参数顺序 ...

  2. unity shader 内置变量

    官网Manual:http://docs.unity3d.com/Manual/SL-UnityShaderVariables.html unity提供大量的内置变量,来供我们使用,主要包括一些 :矩 ...

  3. 编码不规范之将request传参到sevice中

    最近审核团队成员代码,发现确实有很多不规范的地方,其中问题之一就是将request.response.session等参数到传入到sevice层处理,在sevice中通过request对象获取到参数后 ...

  4. 扒站工具Teleport Pro教程

    1.下载软件 http://www.jb51.net/softs/44134.html 2.安装 3.界面 先点开帮助点注册(类似于破解要不全站扒不全) 下面请看ppt, http://www.doc ...

  5. spark远程调试

    基本流程1.远程运行spark,打开Spark master机器的JVM的jdwp,让其阻塞监听指定端口(8888),让其有终端向指定端口发送特定请求再执行:2.IntelliJ配置socket远程连 ...

  6. python模块导入的问题

    从模块导入函数时,通常可以使用 import somemodule 或者 from somemodule import somefunction 或者 from somemodule import s ...

  7. CS231n笔记列表

    课程基础1:Numpy Tutorial 课程基础2:Scipy Matplotlib 1.1 图像分类和Nearest Neighbor分类器 1.2 k-Nearest Neighbor分类器 1 ...

  8. Ueditor/自定义配置

    UEditor除 了具有轻量.可定制等优点外,还始终将优化编辑操作.提升用户体验摆在了很重要的位置.在这一点上,除了对编辑器功能.性能.实现细节等不断地改进和追求 创新之外,众多灵活而人性化的自定义配 ...

  9. Ubuntu中vi命令的使用

    指今说明: 进入 vi 的命令vi filename: 打开或新建文件,并将光标置于第一行首 vi +n filename: 打开文件,并将光标置于第n行首 vi + filename: 打开文件,并 ...

  10. MXF文件结构浅析

    MXF是英文Material eXchange Format(素材交换格式)的缩语.MXF是SMPTE(美国电影与电视工程师学会)组织定义的一种专业音视频媒体文件格式.MXF主要应用于影视行业媒体制作 ...