codechef FEB19 Manhattan Rectangle
Manhattan Rectangle
题意:
交互题,询问小于7次,确定一个矩形的位置,每次询问一个点到矩形的曼哈顿距离。
分析:
询问三个顶点,然后解一下方程,求出一个边界,就好办了。
用scanf和printf会TLE?
代码:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL; const LL D = 1e9; LL Ask(LL x,LL y) {
LL z;
cout << "Q " << x << " " << y << "\n";
cin >> z;
fflush(stdout);
return z;
}
void solve() {
LL a = Ask(0ll, 0ll), b = Ask(D, 0ll), c = Ask(0ll, D);
LL d = Ask((a - b + D) / , ); // !!!
LL y0 = d, x0 = a - d, x1 = D - (b - d), y1 = D - (c - x0);
cout << "A " << x0 << " " << y0 << " " << x1 << " " << y1 << "\n";
int flag;
cin >> flag;
fflush(stdout);
if (flag < ) exit();
}
int main() {
int T ;
cin >> T;
for (; T --; solve()) ;
return ;
}
codechef FEB19 Manhattan Rectangle的更多相关文章
- CodeChef - QRECT Rectangle Query CDQ分治
题目传送门 题解:现在需要维护的每次的询问矩形和前面插入的所有矩形有公共部分的个数. 我们试着直接去维护这个东西, 发现可能的情况太多,不好维护,所以我们维护每次询问的时候在当前矩阵个数下,有多少个矩 ...
- [LeetCode] Perfect Rectangle 完美矩形
Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover o ...
- [LeetCode] Max Sum of Rectangle No Larger Than K 最大矩阵和不超过K
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix s ...
- [LeetCode] Smallest Rectangle Enclosing Black Pixels 包含黑像素的最小矩阵
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black ...
- [LeetCode] Rectangle Area 矩形面积
Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...
- [LeetCode] Maximal Rectangle 最大矩形
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...
- [LeetCode] Largest Rectangle in Histogram 直方图中最大的矩形
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- 【BZOJ-3514】Codechef MARCH14 GERALD07加强版 LinkCutTree + 主席树
3514: Codechef MARCH14 GERALD07加强版 Time Limit: 60 Sec Memory Limit: 256 MBSubmit: 1288 Solved: 490 ...
- Maximal Rectangle
很不好想的一道题,参考:http://blog.csdn.net/doc_sgl/article/details/11832965 分为两步:把原矩阵转为直方图,再用largest rectangle ...
随机推荐
- 远程桌面报错解决:No Remote Desktop License Servers Available
摘 要 用户发来反馈,使用部门Windows跳板机报错:The remote session was disconnected because there are no Remote Desktop ...
- Oracle 补丁那些事儿(PS、PSU、CPU、SPU、BP、DBBP…)
当前ORACLE数据库提供两种方式的补丁一种是主动的Proactive Patches和另一种被动的Reactive Patches,其中Reactive Patches是指过去的ONE-OFF Pa ...
- linux下yum安装指定的mysql版本
因为直接使用yum安装的mysql会是默认版本5.1的版本 但是有的同学不满足又想要其他版本的怎么办呢? 曾时候我来提供一种方案(仅供参考): 我们可以使用rpm包来进行指定mysql版本的安装, ...
- Python学习---JSON补充内容[中文编码 + dumps解析]
JSON补充内容[微信解决中文乱码,接上] import json # 英文显示 dic = {"hello": "world"} str = json.dum ...
- Python学习---IO的异步[twisted模块]
安装twisted模块 Linux: pip3 install twisted Window: a. http://www.lfd.uci.edu/~gohlke/pythonlibs/#twiste ...
- (转)ParallaxOcclusionMapping( POM ) DX9(转)
http://blog.csdn.net/xujiezhige/article/details/7326606
- September 15th 2017 Week 37th Friday
First I need your hand, then forever can begin. 我需要牵着你的手,才能告诉你什么是永远. If you want to shake hands with ...
- CI 2.2 + smarty 3.1.18 完美整合配置成功
CI 2.2 + smarty 3.1.18 配置成功 一.准备文档下载 (CI 框架和smarty) 二.将Smarty-3.1.18 源码包里面的libs文件夹copy到ci的项目目录appli ...
- apache ActiveMQ之初体验
版权声明: https://blog.csdn.net/zdp072/article/details/27237549 一. 开篇语 继上一篇weblogic中使用jms发送和接受消息的文章后, 本文 ...
- 使用transient关键字解决ehcache序列化错误
使用Ehcache时发现个不起眼的小问题 在一个Model中有以下代码: public class MyModel implements Serializable { private static f ...