結果

問題 No.1265 Balloon Survival
ユーザー ktr216ktr216
提出日時 2020-10-23 22:54:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 2,026 ms
コンパイル使用メモリ 177,852 KB
実行使用メモリ 30,652 KB
最終ジャッジ日時 2023-09-28 17:25:04
合計ジャッジ時間 6,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 18 ms
6,216 KB
testcase_15 AC 13 ms
5,588 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 116 ms
25,104 KB
testcase_18 AC 8 ms
4,504 KB
testcase_19 AC 6 ms
4,508 KB
testcase_20 AC 17 ms
6,312 KB
testcase_21 AC 40 ms
10,128 KB
testcase_22 AC 24 ms
8,124 KB
testcase_23 AC 27 ms
8,940 KB
testcase_24 AC 250 ms
30,264 KB
testcase_25 AC 252 ms
30,444 KB
testcase_26 AC 252 ms
30,332 KB
testcase_27 AC 253 ms
30,412 KB
testcase_28 AC 253 ms
30,428 KB
testcase_29 AC 266 ms
30,336 KB
testcase_30 AC 257 ms
30,340 KB
testcase_31 AC 259 ms
30,208 KB
testcase_32 AC 251 ms
30,652 KB
testcase_33 AC 251 ms
30,260 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];
    vector<vector<ll>> d;
    for (ll i = 0; i < N - 1; i++) {
        for (ll j = i + 1; j < N; j++) {
            d.push_back({(x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]), i, j});
        }
    }
    sort(d.begin(), d.end());
    vector<bool> done(N, false);
    ll ans = 0;
    rep(i, d.size()) {
        if (done[d[i][1]] || done[d[i][2]]) continue;
        //cout << d[i][1] << " " << d[i][2] << "\n";
        if (d[i][1] == 0) {
            done[d[i][2]] = true;
            ans++;
        } else {
            done[d[i][1]] = true;
            done[d[i][2]] = true;
        }
    }
    cout << ans << "\n";
}
0