Gym - 100792C Colder-Hotter(三分交互)
Colder-Hotter
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
0
0
1
0
1
0
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:
- Petr names the point (1, 1) and Egor replies 0, because it is the first turn.
- Petr now names the point (0, 0) which is farther from (x = 17, y = 239) than (1, 0), thus Egor replies 0 again.
- Next point is (20, 20), and now the reply is 1.
- Now Petr names (20, 20) again just to show you that the answer for this case is 0, because the relation "closer" is irreflexive.
- 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.
- Egor answers 0 for (17, 240).
- 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(三分交互)的更多相关文章
- Gym 100792C Colder-Hotter (三分)
题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回1,否则返回0,第一次猜一定返回0,在不超过500次的情况下,猜出正确答案. 析:是一个简单的三分 ...
- Gym 101246J Buoys(三分查找)
http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...
- Gym - 101375H MaratonIME gets candies 交互题
交互题介绍:https://loj.ac/problem/6 题意:输出Q X ,读入><= 来猜数,小于50步猜出就算过样例 题解:根本不需要每次输出要打cout.flush()... ...
- Gym - 100851J: Jump(交互+构造+(大胆瞎搞)))
题意:给定长度为N的01串,现在让你猜这个串,猜的次数要不超过N+500次. 每次你猜一个串,系统会返回N/2,或N,或0.当且当有N/2个位置猜对,N个位置猜对,其他. 思路:因为信息不多,没有关联 ...
- github上DQN代码的环境搭建,及运行(Human-Level Control through Deep Reinforcement Learning)conda配置
最近师弟在做DQN的实验,由于是强化学习方面的东西,正好和我现在的研究方向一样于是我便帮忙跑了跑实验,于是就有了今天的这个内容. 首先在github上进行搜寻,如下图: 发现第一个星数最多,而且远高于 ...
- POJ 2540 Hotter Colder --半平面交
题意: 一个(0,0)到(10,10)的矩形,目标点不定,从(0,0)开始走,如果走到新一点是"Hotter",那么意思是离目标点近了,如果是"Colder“,那么就是远 ...
- poj 2540 Hotter Colder 切割多边形
/* poj 2540 Hotter Colder 切割多边形 用两点的中垂线切割多边形,根据冷热来判断要哪一半 然后输出面积 */ #include <stdio.h> #include ...
- POJ 2540 Hotter Colder(半平面交)
Description The children's game Hotter Colder is played as follows. Player A leaves the room while p ...
- 【Gym 100685J】Just Another Disney Problem(交互/排序)
第一次做交互题. 题意是有n个数(n<1000),你通过问1 a b,后台返回你YES代表a<b,NO代表a>b.要你在10000次询问内给出一个符合的排列.n=1000来说,100 ...
随机推荐
- 【ASP.NET Web API2】初识Web API
Web Api 是什么? MSDN:ASP.NET Web API 是一种框架,用于轻松构建可以访问多种客户端(包括浏览器和移动设备)的 HTTP 服务 百度百科:Web API是网络应用程序接口. ...
- Linux查看硬件信息(北桥芯片组、南桥、PCI接口、CPU等)
Linux查看硬件信息(北桥芯片组.南桥.PCI接口.CPU等) Linux查看硬件信息(北桥芯片组.南桥.PCI接口.CPU等) 查看MCH(北桥) 查看ICH(南桥) 查看CPU 查看pci接口设 ...
- redis之 centos 6.7 下安装 redis-3.2.5
前期准备:1. 操作系统需要安装 gcc 包 与 TCL 库, 通过配置本地 yum 源 ,yum -y install gcc . yum -y install tcl安装2. 下载 redis ...
- BZOJ4198:[NOI2015]荷马史诗
浅谈\(Huffman\)树:https://www.cnblogs.com/AKMer/p/10300870.html 题目传送门:https://lydsy.com/JudgeOnline/pro ...
- MySQL 5.7.10 自动备份、自动清理旧备份集(转)
1,mysqldump备份脚本 备份脚本为,里面有几个需要注意的参数: (1)--master-data=2 :这个参数可以在搭建从库的时候,记录当前备份的复制点信息. (2)--extended-i ...
- Linux cciss磁盘设备文件的说明
在某些机器上安装Linux后,发现在/dev目录下找不到hda.hdb.sda等磁盘设备文件,那么挂接的磁盘 在哪里呢?使用mount命令查看挂接设备情况,发现磁盘文件在.dev\cciss目录下,并 ...
- IIS:template
ylbtech-IIS: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 7.返回顶部 8.返回顶部 9.返回顶部 10.返 ...
- 11-03SQLserver基础--子查询语句
一.子查询--查询的嵌套(重点记忆) select MAX(age)from haha where bumen='销售部' --汇总-- select MAX(age)from haha where ...
- 2016上海浦东汽车展览会C+罩杯 车模名单
只能帮你们到这了
- 【259】ucpole.dat update
2017年2月21日 57871 +0.020896 0.007232 +0.414732 0.009212 +0.418044 0.007533 p 57872 +0.022055 0.007284 ...