結果

問題 No.3520 L1等距離点
コンテスト
ユーザー GOTKAKO
提出日時 2026-05-01 21:36:03
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,543 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,367 ms
コンパイル使用メモリ 209,856 KB
実行使用メモリ 30,320 KB
平均クエリ数 7.11
最終ジャッジ日時 2026-05-01 21:36:18
合計ジャッジ時間 13,154 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

using PP = int;
struct Point{
    public:
    PP x,y;
    Point() : x(0),y(0) {}
    Point(PP a,PP b) : x(a),y(b) {}
    Point &operator=(const Point &b) = default;
    Point operator+(const Point &b)const{return Point(x+b.x,y+b.y);}
    Point operator-(const Point &b)const{return Point(x-b.x,y-b.y);}
    Point operator*(const PP &b)const{return Point(x*b,y*b);}
    Point operator/(const PP &b)const{return Point(x/b,y/b);}
    Point &operator+=(const Point &b){return *this=*this+b;}
    Point &operator-=(const Point &b){return *this=*this-b;}
    Point &operator*=(const PP &b){return *this=*this*b;}
    Point &operator/=(const PP &b){return *this=*this/b;}
    friend bool operator<(const Point &a,const Point &b){
        if(a.x == b.x) return a.y < b.y;
        else return a.x < b.x; 
    }
    friend bool operator<=(const Point &a,const Point &b){
        if(a.x == b.x) return a.y <= b.y;
        else return a.x < b.x; 
    }
    friend bool operator==(const Point &a,const Point &b){return a.x==b.x && a.y==b.y;}
    friend bool operator>=(const Point &a,const Point &b){return !(a < b);}
    friend bool operator>(const Point &a,const Point &b){return !(a <= b);}
    friend bool operator!=(const Point &a,const Point &b){return a.x!=b.x || a.y!=b.y;}
 
    friend PP inner(const Point a,const Point b){return a.x*b.x+a.y*b.y;}
    friend PP cross(const Point a,const Point b){return a.x*b.y-a.y*b.x;}
    friend PP twodist(const Point a,const Point b){return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}//2乗で返す.
 
    Point rot(double theta)const{return {PP(x*cos(theta)-y*sin(theta)),PP(x*sin(theta)+y*cos(theta))};} //PP=double限定.
    Point rot90()const{return {-y,x};}
    Point rot180()const{return {-x,-y};}
    Point rot270()const{return {y,-x};}
 
    friend istream &operator>>(istream &is,Point &a){
        is >> a.x >> a.y;
        return is;
    }
    friend ostream &operator<<(ostream &os,const Point &a){
        os << a.x << " " << a.y;
        return os;
    }
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    Point a,b; cin >> a >> b;
    int low = 0,high = T+1;
    while(high-low > 1){
        int mid = (high+low)/2;
        cout << "? " << mid << endl;
        Point c; cin >> c;
        int d = abs(a.x-c.x)+abs(a.y-c.y);
        swap(a,b);
        int d2 = abs(a.x-c.x)+abs(a.y-c.y);
        swap(a,b);
        if(d >= d2) low = mid;
        else high = mid;
    }

    cout << low << endl;
}
0