結果

問題 No.1265 Balloon Survival
ユーザー けーむけーむ
提出日時 2020-12-16 01:55:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,759 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 179,540 KB
実行使用メモリ 16,108 KB
最終ジャッジ日時 2023-10-20 08:45:25
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 13 ms
4,964 KB
testcase_15 AC 10 ms
4,964 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 52 ms
16,104 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 11 ms
4,964 KB
testcase_21 AC 24 ms
7,396 KB
testcase_22 AC 16 ms
7,392 KB
testcase_23 AC 18 ms
7,392 KB
testcase_24 AC 94 ms
16,108 KB
testcase_25 AC 94 ms
16,108 KB
testcase_26 AC 92 ms
16,108 KB
testcase_27 AC 92 ms
16,108 KB
testcase_28 AC 92 ms
16,108 KB
testcase_29 AC 91 ms
16,108 KB
testcase_30 AC 92 ms
16,108 KB
testcase_31 AC 92 ms
16,108 KB
testcase_32 AC 93 ms
16,108 KB
testcase_33 AC 94 ms
16,108 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

ll dist(ll x1, ll y1, ll x2, ll y2) {
    ll dx = x1 - x2;
    ll dy = y1 - y2;
    return dx * dx + dy * dy;
}

struct S {
    ll t1, t2, d;
    
    bool operator<(const S &b) const {
        return d < b.d;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<S> vp;
    rep(i, n) {
        reps(j, i + 1, n) {
            vp.push_back((S){i, j, dist(x[i], y[i], x[j], y[j])});
        }
    }
    sort(all(vp));
    set<ll> deleted;
    ll ans = 0;
    rep(i, sz(vp)) {
        if ((deleted.count(vp[i].t1)) || (deleted.count(vp[i].t2))) {
            continue;
        }
        else if (vp[i].t1 == 0) {
            deleted.insert(vp[i].t2);
            ans++;
        }
        else {
            deleted.insert(vp[i].t1);
            deleted.insert(vp[i].t2);
        }
    }
    cout << ans << endl;
    return 0;
}
0