結果

問題 No.1265 Balloon Survival
ユーザー KudeKude
提出日時 2020-10-23 22:21:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,175 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 211,552 KB
実行使用メモリ 13,132 KB
最終ジャッジ日時 2023-09-28 16:16:01
合計ジャッジ時間 5,431 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 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 2 ms
4,376 KB
testcase_14 AC 14 ms
4,376 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 67 ms
12,768 KB
testcase_18 AC 7 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 14 ms
4,376 KB
testcase_21 AC 29 ms
5,280 KB
testcase_22 AC 19 ms
5,100 KB
testcase_23 AC 20 ms
5,192 KB
testcase_24 AC 129 ms
11,464 KB
testcase_25 AC 132 ms
12,652 KB
testcase_26 AC 137 ms
11,568 KB
testcase_27 AC 138 ms
13,132 KB
testcase_28 AC 135 ms
12,220 KB
testcase_29 AC 132 ms
12,596 KB
testcase_30 AC 130 ms
12,004 KB
testcase_31 AC 137 ms
11,884 KB
testcase_32 AC 141 ms
11,820 KB
testcase_33 AC 137 ms
11,692 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; --i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<ll>;
using VVI = vector<VI>;

ll d2(ll dx, ll dy) {return dx * dx + dy * dy;}

int main() {
    int n;
    cin >> n;
    VI x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    priority_queue<
        tuple<ll,int,int>,
        vector<tuple<ll,int,int>>,
        greater<tuple<ll,int,int>>> q;
    rep(i, n) rep(j, i) {
        // j < i
        q.emplace(d2(x[i]-x[j], y[i]-y[j]), i, j);
    }
    int ans = 0;
    vector<bool> alive(n, true);
    while(!q.empty()) {
        ll d;
        int i, j;
        tie(d, i, j) = q.top(); q.pop();
        if (j == 0) {
            if (alive[i]) {
                ++ans;
                alive[i] = false;
            }
        } else {
            if (alive[i] && alive[j]) {
                alive[i] = alive[j] = false;
            }
        }
    }
    cout << ans << endl;
}
0