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. [C# | XML] XML 反序列化解析错误:<xml xmlns=''> was not expected. 附通用XML到类解析方法

    使用 XML 反化时出现错误: public static TResult GetObjectFromXml<TResult>(string xmlString) { TResult re ...

  2. 使用SharpZipLib压缩与解压文件

    using ICSharpCode.SharpZipLib.Zip; using System; using System.Collections.Generic; using System.IO; ...

  3. [翻译] PJR Signature View

    PJR Signature View https://github.com/paritsohraval100/PJRSignatureDemo It is a UIView subclass by w ...

  4. 也许,这样理解HTTPS更容易

    http://kb.cnblogs.com/page/563885/ 本文尝试一步步还原HTTPS的设计过程,以理解为什么HTTPS最终会是这副模样.但是这并不代表HTTPS的真实设计过程.在阅读本文 ...

  5. Linux file命令详解

    file: 查看文件类型 file常见命令参数 Usage: file [OPTION...] [FILE...] Determine type of FILEs. --help display th ...

  6. 在 vSphere 5.x/6.0 中配置 Network Dump Collector 服务 (2002954)

    vmware KB: https://kb.vmware.com/s/article/2002954?lang=zh_CN 重点配置命令: 使用 vSphere Client 连接到 vCenter ...

  7. 解决windows 10英文版操作系统中VS2017控制台程序打印中文乱码问题

    当您在windows 10英文版的操作系统中运行Vs2017控制台应用程序时,程序可能无法正常显示中文,中文都变成了乱码.这是由于大部分中文程序所使用的文字编码与Windows 英文系统的文字编码不同 ...

  8. MySQL知识总结(三)存储过程

    1. 创建存储过程 1.1 无参数存储过程 CREATE PROCEDURE bruce_procedure () BEGIN --1.声明变量 --2.执行业务逻辑 END 1.2 有参数的存储过程 ...

  9. zookeeper for windows

    1,安装java环境,安装完java之后,添加用户变量.并在命令行中测试 java -version . 2,下载zookeeper http://mirrors.shu.edu.cn/apache/ ...

  10. taskset

    常常感觉系统资源不够用,一台机子上跑了不下3个比较重要的服务,但是每天我们还要在上面进行个备份压缩等处理,网络长时间传输,这在就很影响本就不够用的系统资源: 这个时候我们就可以把一些不太重要的比如co ...