首页 > 其他 > 详细

codechef FEB19 Manhattan Rectangle

时间:2019-02-15 13:14:17      阅读:183      评论:0      收藏:0      [点我收藏+]

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) / 2, 0); // !!! 
    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 < 0) exit(0);
}
int main() {
    int T ;
    cin >> T;
    for (; T --; solve()) ;
    return 0;
}

 

codechef FEB19 Manhattan Rectangle

原文:https://www.cnblogs.com/mjtcn/p/10382821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!