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的更多相关文章

  1. CodeChef - QRECT Rectangle Query CDQ分治

    题目传送门 题解:现在需要维护的每次的询问矩形和前面插入的所有矩形有公共部分的个数. 我们试着直接去维护这个东西, 发现可能的情况太多,不好维护,所以我们维护每次询问的时候在当前矩阵个数下,有多少个矩 ...

  2. [LeetCode] Perfect Rectangle 完美矩形

    Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover o ...

  3. [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 ...

  4. [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 ...

  5. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  6. [LeetCode] Maximal Rectangle 最大矩形

    Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and ...

  7. [LeetCode] Largest Rectangle in Histogram 直方图中最大的矩形

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  8. 【BZOJ-3514】Codechef MARCH14 GERALD07加强版 LinkCutTree + 主席树

    3514: Codechef MARCH14 GERALD07加强版 Time Limit: 60 Sec  Memory Limit: 256 MBSubmit: 1288  Solved: 490 ...

  9. Maximal Rectangle

    很不好想的一道题,参考:http://blog.csdn.net/doc_sgl/article/details/11832965 分为两步:把原矩阵转为直方图,再用largest rectangle ...

随机推荐

  1. [原创]获取JS数组最大值、最小值

    核心关键 JS有Array数组对象,使用prototype内置属性扩展,增加Array数组max().min()方法 具体代码 //最小值 Array.prototype.min = function ...

  2. 什么是 .live()

    很多开发者都知道jQuery的.live()方法,他们大部分知道这个函数做什么,但是并不知道是怎么实现的,所以用的并不那么舒适.而且他们却从未听过还有解除绑定的.live()事件的.die()方法.即 ...

  3. 移动端上下滑动事件之--坑爹的touch.js

    下面的方法,不知道是操作方法不对还是啥.  在 zepto.js 里面加那一段代码不起作用 百度的 touch.js 是可以用的,但是使用方式 和 zepto有点不一样. 解决方案:参照这个链接地址 ...

  4. 深入 Java 调试体系: 第 1 部分,初探JPDA 体系

    JPDA(Java Platform Debugger Architecture)是 Java 平台调试体系结构的缩写,通过 JPDA 提供的 API,开发人员可以方便灵活的搭建 Java 调试应用程 ...

  5. python第十四课--排序及自定义函数之自定义函数(案例一)

    案例一: 演示自定义函数的使用:包含:1).定义格式的掌握2).函数的好处 自定义函数:实现打印矩形的操作两个原则需要考虑:1).有没有形参?有,2个 2).有没有返回值?没有. def printR ...

  6. 1040. [ZJOI2008]骑士【树形DP】

    Description Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英.他们劫富济贫,惩恶扬善,受到社会各 界的赞扬.最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争.战 ...

  7. 【Java123】JDBC数据库连接池建立

    需求场景:多SQL任务多线程并行执行 解决方案:建立JDBC数据库连接池,将线程与连接一对一绑定 https://www.cnblogs.com/panxuejun/p/5920845.html ht ...

  8. Docker实战(五)之端口映射与容器互联

    除了网络访问外,Docker还提供了两个很方便的功能来满足服务访问的基本需求:一个是允许映射容器内应用的服务端口到本地宿主主机;另一个是互联机制实现多个容器间通过容器名来快速访问. 1.端口映射实现访 ...

  9. sar命令使用详解

    一:命令介绍:参考资料:http://linux.die.net/man/1/sar sar(System ActivityReporter系统活动情况报告)是目前Linux上最为全面的系统性能分析工 ...

  10. Putty等工具中解决SSH连接超时断开的问题

    转自:http://www.putty.ws/putty-chaoshi 1 在 linux下的ssh命令:vim /etc/ssh/ssh_config 然后找到里面的ServerAliveInte ...