結果

問題 No.1265 Balloon Survival
ユーザー hamrayhamray
提出日時 2020-11-11 16:49:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 2,448 bytes
コンパイル時間 2,343 ms
コンパイル使用メモリ 156,832 KB
実行使用メモリ 21,048 KB
最終ジャッジ日時 2023-09-30 00:34:59
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 16 ms
5,228 KB
testcase_15 AC 13 ms
5,072 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 71 ms
20,224 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 6 ms
4,384 KB
testcase_20 AC 16 ms
5,220 KB
testcase_21 AC 33 ms
7,516 KB
testcase_22 AC 22 ms
7,780 KB
testcase_23 AC 24 ms
9,320 KB
testcase_24 AC 133 ms
20,640 KB
testcase_25 AC 129 ms
20,436 KB
testcase_26 AC 132 ms
21,048 KB
testcase_27 AC 131 ms
20,900 KB
testcase_28 AC 133 ms
19,780 KB
testcase_29 AC 134 ms
20,572 KB
testcase_30 AC 133 ms
20,096 KB
testcase_31 AC 131 ms
19,800 KB
testcase_32 AC 131 ms
20,600 KB
testcase_33 AC 131 ms
20,560 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).endf()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).endf(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).endf())
#define SORT(c) sort((c).begin(), (c).endf())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const double EPS = 1e-4, PI = acos(-1);
//ここから編集    
typedef string::const_iterator State;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    
    int n; cin >> n;
    vector<ll> x(n), y(n);
    REP(i,n) cin >> x[i] >> y[i];

    vector<bool> used(n, false);
    int ans = 0;
    vector<pair<ll, int>> vp;
    REP(i,n){
        REP(j,n){
            if(i==j) continue;
            ll d = (x[j]-x[i])*(x[j]-x[i]) + (y[j]-y[i])*(y[j]-y[i]);
            vp.push_back({d, i*n+j});
        }
    }
    sort(all(vp));

    REP(i,vp.size()){
        int s = vp[i].second/n, t = vp[i].second%n;
        if(!used[s] && !used[t]){
            if(s == 0){
                ans++;
                used[t] = true;
            }else if(t == 0){
                ans++;
                used[s] = true;
            }else{
                used[t] = used[s] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0