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. 对django rest_framework的个人理解

    首先要搞清楚web service 和rest都是一种API设计的架构,简单点说 作为一个api开发者,为了保证跨语言.跨平台的高效api,我们可以采用架构师提出的设计架构的理念去设计符合条件的api ...

  2. JvisualVm添加远程监控

    一.Weblogic远程监控 1.首先需要在远程的weblogic的域下面,找到/bin/ setDomainEnv.sh ,需要在此文件下加入如下内容: -Dcom.sun.management.j ...

  3. Python函数-bool()

    bool([x]) 作用: 将x转换为Boolean类型,如果x缺省,返回False,bool也为int的子类: 参数x: 任意对象或缺省:大家注意到:这里使用了[x],说明x参数是可有可无的,如果不 ...

  4. bzoj 4403 序列统计——转化成组合数的思路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4403 先说说自己的想法吧. 设f[ i ][ j ]表示当前在倒数第 i 个位置,当前和后面 ...

  5. 1.Linux下Git入门学习

    1.在Linux下安装git软件,使用以下命令: yum install git 2.设置用户名和邮箱(必须): git config --global user.name "Your Na ...

  6. flask+blueprint路由配置

    1.flask默认的静态文件和html文件在app应用文件夹里的相应文件夹下:app // Flask||--static ||--templates |静态文件默认的url地址为:url_prefi ...

  7. AWS + Stunnel + Squid ***

    [需求] 第一,能***. 第二,在企业网络要能突破端口限制. [原理] 利用AWS提供的一年免费EC2服务,搭建一台自己的VPS,在VPS中利用Stunnel与本机建立加密连接,将本地http请求通 ...

  8. sql server将字符串转换为 uniqueidentifier 时失败

    sql server查询中出现 将字符串转换为 uniqueidentifier 时失败异常 原因为id设置为uniqueidentifier 字段,在where查询时需要做转换cast(id as ...

  9. MySQL 学习四 SQL优化

    MySQL逻辑架构: 第一层:客户端层,连接处理,授权认证,安全等功能.   第二层:核心层,查询解析,分析,优化,缓存,内置函数(时间,数学,加密),存储过程,触发器,视图   第三层:存储引擎.负 ...

  10. 开发环境入门 linux基础 (部分)网络 SSH 更名 DNS解析 元字符

    nginx---> web ifconfig 查看网络配置信息 id add show 查看当前网卡信息(最小安装下) mtu 是指网卡传输的最大单元 单位:字节 网卡配置 临时配置 ifcon ...