結果

問題 No.168 ものさし
ユーザー nicklaw296nicklaw296
提出日時 2018-01-11 21:53:47
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,270 bytes
コンパイル時間 1,482 ms
コンパイル使用メモリ 150,512 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-25 04:06:29
合計ジャッジ時間 5,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool check(long long int)’:
main.cpp:18:18: warning: control reaches end of non-void function [-Wreturn-type]
     queue<Point> que;
                  ^~~

ソースコード

diff #

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

struct Point{
    long long int n, x, y;
};

int n;
vector<Point> v;

long long int get_distance(Point a, Point b){
    return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
}

bool check(long long int x){
    bool visited[n];
    for(int i=0;i<n;++i)visited[i] = false;
    queue<Point> que;
    visited[0] = true;
    que.push(v[0]);
    while(!que.empty()){
        Point curr = que.front(); que.pop();
        if(curr.n == n-1)return true;
        for(int i=1;i<n;++i){
            if(!visited[i] && get_distance(v[i], curr) <= x){
                que.push(v[i]);
                visited[i] = true;
            }
        }
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n;++i){
        int x, y;
        cin >> x >> y;
        v.push_back((Point){i, x, y});
    }
    long long int ok = 2000000000000000000, ng = 0;
    while(abs(ok-ng) > 1){
        long long int mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    long long int lb = 0, ub = 1414213563;
    while(abs(ub-lb) > 1){
        long long int mid = (ub + lb) / 2;
        if(mid * mid < ok)lb = mid;
        else ub = mid;
    }
    if((ub%10) != 0)ub += 10 - (ub%10);
    cout << ub << endl;

    return 0;
}
0