結果

問題 No.1265 Balloon Survival
ユーザー oevloevl
提出日時 2020-10-27 02:37:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 984 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 210,176 KB
実行使用メモリ 12,948 KB
最終ジャッジ日時 2023-09-29 03:09:02
合計ジャッジ時間 5,644 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 10 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 57 ms
11,444 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 26 ms
5,240 KB
testcase_22 AC 17 ms
5,064 KB
testcase_23 AC 18 ms
4,920 KB
testcase_24 AC 117 ms
12,380 KB
testcase_25 AC 118 ms
12,948 KB
testcase_26 AC 121 ms
12,132 KB
testcase_27 AC 121 ms
11,452 KB
testcase_28 AC 119 ms
11,392 KB
testcase_29 AC 118 ms
12,276 KB
testcase_30 AC 118 ms
12,864 KB
testcase_31 AC 120 ms
11,588 KB
testcase_32 AC 119 ms
11,620 KB
testcase_33 AC 120 ms
12,812 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using T = tuple<long long, int, int>;

int main() {
    int n; cin >> n;
    vector<P> ps(n);
    for(auto &[x, y] : ps) cin >> x >> y;

    auto distance = [&](auto p, auto p2) -> long long {
        auto[x, y] = p;
        auto[x2, y2] = p2;
        long long dx = x - x2;
        long long dy = y - y2;
        return dx * dx + dy * dy;
    };

    priority_queue<T, vector<T>, greater<T>> que;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j < n; ++j) {
            que.emplace(distance(ps[i], ps[j]), i, j);
        }
    }

    int ans = 0;
    vector<bool> burst(n);
    while(!que.empty()) {
        auto[d, i, j] = que.top();
        que.pop();
        if(burst[i] || burst[j]) continue;
        if(i == 0) {
            burst[j] = true;
            ans++;
        } else {
            burst[i] = true;
            burst[j] = true;
        }
    }
    cout << ans << '\n';
    return 0;
}
0