結果

問題 No.1265 Balloon Survival
ユーザー trineutrontrineutron
提出日時 2020-10-23 23:22:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 2,442 ms
コンパイル使用メモリ 215,728 KB
実行使用メモリ 20,748 KB
最終ジャッジ日時 2023-09-28 18:35:48
合計ジャッジ時間 4,780 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 10 ms
5,052 KB
testcase_15 AC 8 ms
4,880 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 39 ms
16,120 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 10 ms
5,024 KB
testcase_21 AC 19 ms
7,172 KB
testcase_22 AC 13 ms
6,516 KB
testcase_23 AC 13 ms
6,468 KB
testcase_24 AC 70 ms
19,472 KB
testcase_25 AC 69 ms
20,164 KB
testcase_26 AC 69 ms
20,748 KB
testcase_27 AC 70 ms
19,616 KB
testcase_28 AC 69 ms
19,492 KB
testcase_29 AC 70 ms
19,988 KB
testcase_30 AC 69 ms
19,472 KB
testcase_31 AC 69 ms
20,516 KB
testcase_32 AC 69 ms
20,092 KB
testcase_33 AC 70 ms
19,776 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n;
    cin >> n;
    vector<int64_t> x(n), y(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i) >> y.at(i);
    }
    vector d(n, vector(n, 0L));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int64_t dx = x.at(i) - x.at(j), dy = y.at(i) - y.at(j);
            d.at(i).at(j) = dx * dx + dy * dy;
        }
    }
    vector<tuple<int64_t, int, int>> p;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            p.emplace_back(d.at(i).at(j), i, j);
        }
    }
    sort(p.begin(), p.end());
    int ans = 0;
    vector<bool> disappeared(n);
    for (auto x : p) {
        auto [_, a, b] = x;
        if (disappeared.at(a) or disappeared.at(b)) continue;
        if (a == 0) {
            disappeared.at(b) = true;
            ans++;
        } else {
            disappeared.at(a) = true;
            disappeared.at(b) = true;
        }
    }
    cout << ans << endl;
}
0