結果

問題 No.1265 Balloon Survival
ユーザー naribownaribow
提出日時 2020-10-23 23:40:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 1,859 bytes
コンパイル時間 2,797 ms
コンパイル使用メモリ 209,796 KB
実行使用メモリ 10,672 KB
最終ジャッジ日時 2023-09-28 18:57:16
合計ジャッジ時間 5,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 10 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 40 ms
9,476 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 19 ms
4,728 KB
testcase_22 AC 13 ms
4,752 KB
testcase_23 AC 14 ms
4,876 KB
testcase_24 AC 72 ms
10,492 KB
testcase_25 AC 73 ms
9,268 KB
testcase_26 AC 73 ms
10,212 KB
testcase_27 AC 73 ms
10,472 KB
testcase_28 AC 72 ms
9,792 KB
testcase_29 AC 73 ms
9,944 KB
testcase_30 AC 72 ms
10,672 KB
testcase_31 AC 73 ms
9,668 KB
testcase_32 AC 74 ms
9,984 KB
testcase_33 AC 72 ms
10,604 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;
typedef long long ll;
const double pi = 3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF = 1e18;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

ll dis (pair<ll, ll> a, pair<ll, ll> b) {
    return (ll)(a.first - b.first) * (ll)(a.first - b.first) + (ll)(a.second - b.second) * (ll)(a.second - b.second);
}

int main() {
    ll n;
    cin >> n;
    vector<P> xy(n);
    rep(i, n) {
        cin >> xy[i].first >> xy[i].second;
    }
    vector<pair<int, pair<int , int> > > kn;
    vector<bool> used(n, false);
    rep2(i, 0, n-1) {
        ll this_dis = INF, ind = -1;
        rep2(j, i+1, n) {
            if(i == j) continue;
            ll dis_y = dis(xy[i], xy[j]);
            pair<int, pair<int, int> > k;
            k.first = floor(sqrtl(dis_y) + 0.999999999);
            k.second.first = i;
            k.second.second = j;
            kn.emplace_back(k);
        }
    }
    sort(kn.begin(), kn.end());
    int ans = 0;
    rep(i, kn.size()) {
        int a = kn[i].second.first;
        int b = kn[i].second.second;
        if(used[a] == false && used[b] == false ) {
            if(a == 0) {
                used[b] = true;
                ans++;
            }
            else if(b == 0) {
                used[a] = true;
                ans++;
            }
            else {
                used[a] = true;
                used[b] = true;
            }
        }
    }

    cout << ans << endl;
}
0