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. 进程间协作---wait,notify,notifyAll

    转自牛客网的一篇评论,解释的十分详细 在 Java 中,可以通过配合调用 Object 对象的 wait() 方法和 notify()方法或 notifyAll() 方法来实现线程间的通信.在线程中调 ...

  2. 修改UIView的默认Layer后,修改View的值会动态修改Layer的值

    修改UIView的默认Layer后,修改View的值会动态修改Layer的值 效果图: 如上图所示,当我们修改了一个UIView的子类中的Layer内置类型时(如上图中我们将CALayer直接替换成了 ...

  3. 如何生成.mobileprovision文件

    如何生成.mobileprovision文件 本人视频教程系列 **.mobileprovision文件的生成的第一步就需要你提供一个用于开发的App ID 1. 创建App ID 创建一个bundl ...

  4. Spring MVC Hello World 404

    下面的例子说明了如何使用 Spring MVC 框架来编写一个简单的基于 web 的 Hello World 应用程序.下面让我们使用 Eclipse IDE,然后按照下面的步骤使用 Spring 的 ...

  5. jquery ztree的案例,附源代码

    播客:http://itindex.net/detail/46094-jquery-ztree-%E7%A8%8B%E5%BA%8F   源代码: http://download.csdn.net/d ...

  6. September 14th 2017 Week 37th Thursday

    Don't let the past steal your present. 别让过去悄悄偷走了我们的当下. We take what we can get and make the best of ...

  7. tomcat-7.0.30安装及配置

    使用说明: 一.1.下载jdk(http://java.sun.com/javase/downloads/index.jsp),2.安装jdk-6u14-windows-i586.exe 3.配置环境 ...

  8. 智能指针shared_ptr新特性shared_from_this及weak_ptr

    enable_shared_from_this是一个模板类,定义于头文件<memory>,其原型为: template< class T > class enable_shar ...

  9. 使用ubuntu desktop是可能会用到的配置

    1.ubuntu desktop12.04 接双显示器 想要12.04版本在接上双显示器时能很好的工作,则需要进行如下设置: (1).编辑/etc/X11/xorg.conf文件: /etc/X11/ ...

  10. 浅析JS中的堆内存与栈内存

    最近跟着组里的大佬面试碰到这么一个问题, Q:说说var.let.const的区别 A:balabalabalabla... Q:const定义的值能改么? A:你逗我?不能吧 不知道各位看官怎么想? ...