Gym 100792C Colder-Hotter (三分)
题意:系统有一个点对,让你去猜,每次你猜一个,如果这个数和系统里的那个点距离比上一个你猜的近,那么返回1,否则返回0,第一次猜一定返回0,在不超过500次的情况下,猜出正确答案。
析:是一个简单的三分,横纵坐标可以分开来考虑,每次两次三分,然后看那个点更偏向哪边即可,注意这个题,有一个坑,那就是你输出的点不能超过1e9,即使是在运算过程中也不行,也就是说上界必须是 1e9,其他的都不对,我就写了1e9+1,WA到死。。。。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define pu push_up
#define pd push_down
#define cl clear()
#define FOR(x,n) for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
#define pii pair<int, int>
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e18;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 18260 + 100;
const LL mod = 1000000007;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c) {
return r > 0 && r <= n && c > 0 && c <= m;
} int main(){
int ansx = 0, ansy = 1e9;
int cnt = 0, x1, x2;
int idx = 0;
while(ansx < ansy){
int m1 = ansx + (ansy - ansx) / 3;
int m2 = ansy - (ansy - ansx) / 3;
cout << 0 << " " << m1 << endl << endl;
cout.flush();
cin >> x1; cout << 0 << " " << m2 << endl << endl;
cout.flush();
cin >> x2;
if(x2 == 1) ansx = m1 + 1;
else ansy = m2 - 1;
cnt += 2;
if(cnt > 500) assert(0);
}
int ansxx = ansx;
ansx = 0, ansy = 1e9;
idx = 0;
while(ansx < ansy){
int m1 = ansx + (ansy - ansx) / 3;
int m2 = ansy - (ansy - ansx) / 3;
cout << m1 << " " << ansxx << endl << endl;
cout.flush();
cin >> x1; cout << m2 << " " << ansxx << endl << endl;
cout.flush();
cin >> x2;
if(x2 == 1) ansx = m1 + 1;
else ansy = m2 - 1;
cnt += 2;
if(cnt > 500) assert(0);
}
cout << "A " << ansx << " " << ansxx << endl;
return 0;
}
Gym 100792C Colder-Hotter (三分)的更多相关文章
- Gym - 100792C Colder-Hotter(三分交互)
Colder-Hotter Statements This is an interactive problem. Egor and Petr are playing a game called «Co ...
- Gym 101246J Buoys(三分查找)
http://codeforces.com/gym/101246/problem/J 题意: 给定x轴上的n个点的坐标,按顺序从左到右给出,现在要使得每个点的间距相同,可以移动每个点的坐标,但是不能改 ...
- 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 - 101309D - Dome of Circus
容易发现,圆锥体积和点的具体x.y坐标无关,只与其到z轴的距离sqrt(x*x+y*y)有关. 于是将这些三维的点都投射到二维的xOy平面的第二象限(sqrt(x*x+y*y),z),求个上凸壳,然后 ...
- Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)
题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...
- POJ 2540 Hotter Colder
http://poj.org/problem?id=2540 题意:给你每次行走的路径,而且告诉你每次离一个点光源是远了还是近了,要求每次光源可能存在的位置的面积. 思路:如果出现"same ...
- codeforces GYM 100971F 公式题或者三分
F. Two Points time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
随机推荐
- Ubuntu下VIM使用指南
基本命令: Esc:VIM中的万能功能键之一,基本上任何时候按这个键,都可以返回VIM的普通状态. i:在普通状态下按i可以进入“插入”编辑状态,这个时候按方向键移动光标,在想要输入的地方输入字符,用 ...
- Unity容器声明周期管理
Having said that, here is a solution that you can use with the Unity container: Create some custom a ...
- Linux gdb调试器用法全面解析
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具,GDB主要可帮助工程师完成下面4个方面的功能: 启动程序,可以按照工程师自定义的要求随心所欲的运行程序. 让被调试的程序在工程师指定的断 ...
- PyQt5系列教程(二)利用QtDesigner设计UI界面
软硬件环境 OS X EI Capitan Python 3.5.1 PyQt 5.5.1 PyCharm 5.0.1 前言 在PyQt5系列教程的第一篇http://blog.csdn.net/dj ...
- Pthreads 环境配置,VisualStudio
▶ Visual Studio 下配置MPI环境 ● 下载 Pthreads(http://pthreads.org/),解压. ● 针对 x64 程序的配置 ■ 将 Pre-built.2\incl ...
- 529. Minesweeper
▶ 扫雷的扩展判定.已知棋盘上所有点的情况(雷区 'M',已翻开空白区 'B',未翻开空白区 'E',数字区 '1' ~ '8'),现在给定一个点击位置(一定在空白区域),若命中雷区则将被命中的 M ...
- Supervisor安装与配置
Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统 ...
- javascript instanceof,typeof的区别
区分string 与 String的区别 为什么结果会是false呢? <script type="text/javascript"> var aColors = [& ...
- leetcode475
public class Solution { public int FindRadius(int[] houses, int[] heaters) { houses = houses.Distinc ...
- XE: Changing the default http port
Oracle XE uses the embedded http listener that comes with the XML DB (XDB) to serve http requests. T ...