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 ...
随机推荐
- [HihoCoder1413]Rikka with String
vjudge 题意 给你一个串,问你把每个位置的字符替换成#后串中有多少本质不同的子串. \(n\le 3*10^5\) sol 首先可以计算出原串里面有多少本质不同的子串.显然就是\(\sum_{i ...
- 基于SSL的WCF传输安全
[实践]WCF传输安全1:前期准备之证书制作 [实践]WCF传输安全2:基于SSL的WCF匿名客户端 [实践]WCF传输安全3:基于SSL的WCF对客户端验证 [实践]WCF传输安全4:基 ...
- 预备架构的工具ADMEMS矩阵
矩阵,是很多著名方法的核心.例如,制定公司层战略的方法之一是"波士顿矩阵","波士顿矩阵"又称"市场增长率-相对市场份额矩阵". " ...
- WPF中ItemsControl绑定到Google ProtocolBuffer的结构体时的性能问题
背景: 最近遇到一个DataGrid的性能问题:里面大概有4000个数据, 绑定的ItemSource的类也只有一层数据,即简单的List(里面每个是Protocol Buffer自动产生的一个类,1 ...
- 通过Python查看Azure VM的状态
Azure的管理平台采用Restful API的方式实现管理.比如获取VM的管理API的各种操作的文档请参考: https://docs.microsoft.com/en-us/rest/api/co ...
- RazorHelper.cs
完整版 RazorHelper.cs using System; using System.Collections; using System.Collections.Generic; using S ...
- Linux cciss磁盘设备文件的说明
在某些机器上安装Linux后,发现在/dev目录下找不到hda.hdb.sda等磁盘设备文件,那么挂接的磁盘 在哪里呢?使用mount命令查看挂接设备情况,发现磁盘文件在.dev\cciss目录下,并 ...
- expected declaration specifiers or '...' before string constant
/work/platform_bus_dev_drv/led_dev.c:52: error: expected declaration specifiers or '...' before stri ...
- 火星坐标、百度坐标、WGS84坐标转换代码(JS)
JS版本源码 /** * Created by Wandergis on 2015/7/8. * 提供了百度坐标(BD09).国测局坐标(火星坐标,GCJ02).和WGS84坐标系之间的转换 */ / ...
- Java 中的关键字和保留字
关键字: Java 语言中已经事先定义好了的,有着特殊含义和用途 访问控制 类.方法和变量修饰符 程序控制 异常处理 包相关 基本类型 变量引用 public abstract break try i ...