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 ...
随机推荐
- Cash Machine(多重背包二进制转换)
个人心得:多重背包,自己根据转换方程写总是TLE,后面去网上看了二进制转换,不太理解: 后面仔细想了下,用自己的思想理解下把,就是将对应number,cash总和用二进制拆分, 然后全部装入到一个数组 ...
- webpack入门(四)——webpack loader 和plugin
什么是loader loaders是你用在app源码上的转换元件.他们是用node.js运行的,把源文件作为参数,返回新的资源的函数. 例如,你可以用loaders告诉webpack加载 coffee ...
- 微信小程序编写物流信息进度样式
做电商类型的小程序一定会碰到编写物流信息的时候,一般页面如下图 难点在于只有一条信息时候的页面样式 以及多条信息最后一条信息的页面样式 之前没做过这一块的东西,所以刚碰到的时候想了老半天orz.后来上 ...
- Oracle存储过程创建及调用
在大型数据库系统中,有两个很重要作用的功能,那就是存储过程和触发器.在数据库系统中无论是存储过程还是触发器,都是通过SQL 语句和控制流程语句的集合来完成的.相对来说,数据库系统中的触发器也是一种存储 ...
- CF884D:Boxes And Balls
浅谈\(Huffman\)树:https://www.cnblogs.com/AKMer/p/10300870.html 题目传送门:https://codeforces.com/problemset ...
- 在系统学习javaEE开发的颠覆者Springboot时遇到的localhost无法访问的问题
就是新建了一个Springboot项目,但是无法正常访问. 关闭防火墙试了,mvn方式启动试了,换端口试了.然后用Tomcat的start.bat测试发现localhost是可以访问的. 上网找到各种 ...
- Oracle RMAN 学习:演练进阶篇
Oracle RMAN 学习:演练进阶篇 5 Rman备份演练进阶篇 5.1 是否选择增量备份 Backup命令生成的备份集中只备份了那些使用了的数据块,备份集实际大小已经较目标数据库的数据文件小了很 ...
- “百度杯”CTF比赛 2017 二月场(Misc Web)
爆破-1: 打开链接,是502 我直接在后面加个变量传参数:?a=1 出了一段代码 var_dump()函数中,用了$$a,可能用了超全局变量GLOBALS 给hello参数传个GLOBALS 得到f ...
- Hibernate面试总结
SSH原理总结 Hibernate工作原理及为什么要用: 原理: hibernate,通过对jdbc进行封装,对 java类和 关系数据库进行mapping,实现了对关系数据库的面向对象方式的操作,改 ...
- Ubuntu16.04 Hadoop2.6.0伪分布式安装与启动中遇到的问题
1.安装JDK1.8,下载安装包解压至 /usr/lib/jdk vim /etc/profile #配置路径 export JAVA_HOME= /usr/lib/jdk export JRE_HO ...