結果

問題 No.2179 Planet Traveler
ユーザー eve__fuyukieve__fuyuki
提出日時 2023-11-29 12:46:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,415 bytes
コンパイル時間 2,502 ms
コンパイル使用メモリ 219,480 KB
実行使用メモリ 20,272 KB
最終ジャッジ日時 2023-11-29 12:46:43
合計ジャッジ時間 6,231 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 206 ms
20,272 KB
testcase_14 AC 78 ms
20,272 KB
testcase_15 AC 80 ms
20,272 KB
testcase_16 AC 79 ms
20,272 KB
testcase_17 AC 184 ms
20,272 KB
testcase_18 WA -
testcase_19 AC 180 ms
20,272 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 107 ms
12,072 KB
testcase_23 WA -
testcase_24 AC 148 ms
12,076 KB
testcase_25 AC 115 ms
12,072 KB
testcase_26 AC 162 ms
20,272 KB
testcase_27 WA -
testcase_28 AC 78 ms
12,068 KB
testcase_29 AC 147 ms
12,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
void fast_io() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
long long sq_floor(long long x) {
    long long lo = 0, hi = 9e9;
    while (lo + 1 < hi) {
        long long mid = (lo + hi) / 2;
        if (mid * mid <= x) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    return lo;
}

int main() {
    fast_io();
    int n;
    cin >> n;
    vector<long long> x(n), y(n), t(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> t[i];
    }
    vector<long long> r(n);
    for (int i = 0; i < n; i++) {
        r[i] = x[i] * x[i] + y[i] * y[i];
    }
    vector<tuple<long long, int, int>> edges;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (t[i] == t[j]) {
                edges.push_back({(x[i] - x[j]) * (x[i] - x[j]) +
                                     (y[i] - y[j]) * (y[i] - y[j]),
                                 i, j});
            } else {
                edges.push_back(
                    {r[i] + r[j] - 2 * sq_floor((long long)r[i] * r[j]), i, j});
            }
        }
    }
    sort(edges.begin(), edges.end());
    dsu uf(n);
    for (auto [w, u, v] : edges) {
        uf.merge(u, v);
        if (uf.same(0, n - 1)) {
            cout << w << endl;
            return 0;
        }
    }
}
0