ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter
1 second
512 megabytes
standard input
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.
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.
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.
0
0
1
0
1
0
1 1
0 0
20 20
20 20
17 239
17 240
A 17 239
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();
题意:交互题。
有一个坐标 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)
队名:Unlimited Code Works(无尽编码) 队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...
- Moscow Subregional 2013. 部分题题解 (6/12)
Moscow Subregional 2013. 比赛连接 http://opentrains.snarknews.info/~ejudge/team.cgi?contest_id=006570 总叙 ...
随机推荐
- sehll_if
-s file 文件大小非0时为真 [ -f "somefile" ] :判断是否是一个文件[ -x "/bin/ls" ] :判断/bin/ls是否存在并有可 ...
- 数据结构和算法 – 8.链表
8.1.数组存在的问题 在处理列表的时候数组是常用的数据结构.数组可以对所存储的数据项提供快速地存取访问,而且它很易于进行循环遍历操作.当然,数组已经是语言的一部分了,用户不需要使用额外的内存,也不需 ...
- Sublime Text + CTags + Cscope (部分替代Source Insight)
CTags & cscope 下载: CTags+Cscope --- 我的百度云盘下载http://pan.baidu.com/s/1gfyPnuN ctags58.zip --- src ...
- POJ3685 Matrix(嵌套二分)
同行元素递减,同列元素递增,采用嵌套二分的方法 #include<cstdio> #include<iostream> #include<cstdlib> #inc ...
- oracle检查点队列(checkpoint queue)
buffer cache CBC链 按地址链 LRU 干净buffer LRUW 脏buffer 按照冷热 checkpoint queue:链buffer,①链脏块②按buffer第一次脏的时 ...
- phpcms调用一级栏目和二级栏目
{loop subcat(,,,$siteid) $r} {php $num++} <strong><a href=} <br /> {elseif $n!=$c} | ...
- [JavaCore] 微信手机浏览器版本判断
公司要做微支付,微信浏览器版本要大于5 package com.garinzhang.web.weixin; import org.apache.commons.lang.StringUtils; i ...
- The Basics of 3D Printing in 2015 - from someone with 16 WHOLE HOURS' experience
全文转载自 Scott Hanselman的博文. I bought a 3D printer on Friday, specifically a Printrbot Simple Metal fro ...
- iOS经典面试题(转)
iOS经典面试题 前言 写这篇文章的目的是因为前两天同学想应聘iOS开发,从网上找了iOS面试题和答案让我帮忙看看.我扫了一眼,倒吸了一口冷气,仔细一看,气的发抖.整篇题目30多个没有一个答案是对 ...
- dojo.publish 和 dojo.subscribe
原文链接:http://www.cnblogs.com/didi/archive/2010/06/13/1757894.html //dojo.publish 和 dojo.subscribe :d ...