結果

問題 No.168 ものさし
ユーザー uenokuuenoku
提出日時 2017-01-24 23:43:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,498 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 83,756 KB
実行使用メモリ 11,996 KB
最終ジャッジ日時 2023-08-24 21:56:38
合計ジャッジ時間 7,232 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:102:34: 警告: overflow in conversion from ‘double’ to ‘long long unsigned int’ changes value from ‘2.0e+19’ to ‘18446744073709551615’ [-Woverflow]
  102 |     unsigned long long int u = 2 * 1e19;
      |                                ~~^~~~~~

ソースコード

diff #

#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define SIZE 200005
#define UF_MAX 100005
using namespace std;
typedef long double ld;
typedef long long int lli;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
lli MOD = 1000000007;
#define UF_MAX 100005
struct UFind {
    int par[UF_MAX];
    int rank[UF_MAX];
    int count[UF_MAX];
    UFind(int n)
    {
        rep(i, n)
        {
            par[i] = i;
            rank[i] = 0;
            count[i] = 1;
        }
    }
    int find(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            count[y] += count[x];
        } else {
            par[y] = x;
            count[x] += count[y];
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};
struct edge {
    lli f, t, len;
};
lli n2(lli x1, lli x2, lli y1, lli y2)
{
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main()
{
    int n;
    cin >> n;
    lli a, b;
    unsigned long long int up = 1e19;
    unsigned long long int low = 0;
    lli x[1005], y[1005];
    rep(i, n)
    {
        cin >> x[i] >> y[i];
    }
    while (up - low > 1) {
        lli mid = (up + low) / 2;
        //cout << mid << endl;
        UFind uf(n);
        rep(i, n) rep(j, n)
        {
            if (n2(x[i], x[j], y[i], y[j]) <= mid) {
                uf.unite(i, j);
            }
        }
        bool flag = uf.same(0, n - 1);
        if (flag) {
            up = mid;
        } else {
            low = mid;
        }
    }
    unsigned long long int u = 2 * 1e19;
    unsigned long long int l = 0;
    while (u - l > 1) {
        unsigned long long int mid = (u + l) / 2;
        if (mid * mid >= up) {
            u = mid;
        } else {
            l = mid;
        }
    }
    if (u % 10)
        u = u + 10 - u % 10;
    cout << u << endl;
}
0