結果

問題 No.1265 Balloon Survival
ユーザー sten_sansten_san
提出日時 2020-10-29 18:57:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 210,800 KB
実行使用メモリ 11,160 KB
最終ジャッジ日時 2023-09-29 04:03:59
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 61 ms
9,796 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 27 ms
4,732 KB
testcase_22 AC 17 ms
4,592 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,380 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;
template <typename T> using vvec = vector<vector<T>>;

int main() {
    int n; cin >> n;
    vec<array<int, 2>> bal(n);
    for (auto &[x, y]: bal) cin >> x >> y;

    using dist_t = array<int, 3>;
    priority_queue<dist_t, vector<dist_t>, greater<dist_t>> que;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            que.push({ (max(abs(bal[i][0] - bal[j][0]), abs(bal[i][1] - bal[j][1])) + 1) / 2, i, j });
        }
    }

    int ans = 0;

    vec<bool> used(n, false);
    while (que.size()) {
        auto [d, a, b] = que.top(); que.pop();
        if (used[a] || used[b]) continue;

        tie(a, b) = make_tuple(min(a, b), max(a, b));
        used[a] = a != 0;
        used[b] = true;

        ans += a == 0;
    }

    cout << ans << endl;
}

0