C. Colder-Hotter
time limit per test

1 second

memory limit per test

512 megabytes

input

standard input

output

standard output

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.

Sample test(s)
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();

题意:交互题。

有一个坐标 X,Y,你可以进行询问,每一次询问,他都会返回0/1,如果你的点比上一个点接近生成坐标,则会返回1,否则0

分析:显然是先确定x坐标,在确定y的坐标。

联想到距离公式,三分即可

 /**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} int ans[]; bool Check(int x, int y, int w)
{
static int tmp[];
int ret;
tmp[w] = x, tmp[w ^ ] = ans[w ^ ];
//printf("%d %d\n", tmp[0], tmp[1]);
cout << tmp[] << ' ' << tmp[] << endl;
//scanf("%d", &ret);
cin >> ret;
tmp[w] = y;
//printf("%d %d\n", tmp[0], tmp[1]);
cout << tmp[] << ' ' << tmp[] << endl;
//scanf("%d", &ret);
cin >> ret;
return ret;
} inline void Work(int w)
{
int left = , right = INF - ;
while(right - left + > )
{
int d = (right - left) / ;
int x = left + d;
int y = right - d;
bool better = Check(x, y, w);
if(better) left = x;
else right = y;
}
int ret = right;
for(int i = left; i < right; i++)
{
bool better = Check(i, i + , w);
if(!better)
{
ret = i;
break;
}
}
ans[w] = ret;
} inline void Solve()
{
//printf("0 0\n");
ans[] = ;
Work();
Work(); cout << "A " << ans[] << ' ' << ans[] << endl;
//printf("A %d %d\n", ans[0], ans[1]);
} int main()
{
//freopen("", "r", stdin);
Solve();
return ;
}

ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter的更多相关文章

  1. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering

    Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...

  2. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time

    Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second M ...

  3. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?

    I. Illegal or Not? time limit per test 1 second memory limit per test 512 megabytes input standard i ...

  4. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout

    K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...

  5. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 H. Hashing

    H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input out ...

  6. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 A. Anagrams

    A. Anagrams time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...

  7. hdu 5444 Elven Postman(二叉树)——2015 ACM/ICPC Asia Regional Changchun Online

    Problem Description Elves are very peculiar creatures. As we all know, they can live for a very long ...

  8. 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)

    队名:Unlimited Code Works(无尽编码)  队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...

  9. Moscow Subregional 2013. 部分题题解 (6/12)

    Moscow Subregional 2013. 比赛连接 http://opentrains.snarknews.info/~ejudge/team.cgi?contest_id=006570 总叙 ...

随机推荐

  1. zTree控件的使用

    最常用的使用方式是json格式 .net递归实现对象生成json格式字符串 代码: using System; using System.Collections.Generic; using Syst ...

  2. Android请求服务器的两种方式--post, get的区别

    android中用get和post方式向服务器提交请求_疯狂之桥_新浪博客http://blog.sina.com.cn/s/blog_a46817ff01017yxt.html Android提交数 ...

  3. 如何减少JS的全局变量污染

    A,唯一变量 B,闭包

  4. JAVA中this用法小结

    Java关键字this只能用于方法方法体内.当一个对象创建后,Java虚拟机(JVM)就会给这个对象分配一个引用自身的指针,这个指针的名字就是 this.因此,this只能在类中的非静态方法中使用,静 ...

  5. oracle使用dbms_metadata包取得所有对象DDL语句

    当我们想要查看某个表或者是表空间的DDL的时候,可以利用dbms_metadata.get_ddl这个包来查看. dbms_metadata包中的get_ddl函数详细参数 GET_DDL函数返回创建 ...

  6. .NET NLog 详解(四) - filter

    我们将版本向前切换到20051025,这期的关注点是filter.我们在使用日志的时候可能希望加上一些过滤器,在满足某些特定条件的时候才输出.举个简单的使用方式如下: <nlog> < ...

  7. JavaScript - BOM

    window 对象 window 对象是BOM的核心对象,也是ECMAScript规定的Global对象. 无法跨浏览精确获得窗口左边和上边的精确值,同样也无法确定浏览器窗口本身的大小,但是可以取得页 ...

  8. Android JNI开发生成.h头文件问题(转)

    在JNI开发中,首先要将建立的anroid类编译成.h文件,编译用到命令javah,由于第一次用,以前对java的编译过程也不怎么了解,所以走了好多弯路,网络没有对这一步的详细介绍,这里讲一下: 通过 ...

  9. 软引用SoftReference异步加载图片

    HashMap<String, SoftReference<Drawable>> imageCache 关于SoftReference这个类多少知道些机制,会用就ok了. 机制 ...

  10. 【J2EE入门】13个规范

    看过了j2ee教学视频,真的让我痛彻心扉,那叫痛并快乐着,痛是因为看了这么长时间,自己只知道了13个规范的概念:同样,快乐也正是因为我知道了13个规范的概念,接下来就是逐项实践的学习. 看了教学视频, ...