結果

問題 No.1265 Balloon Survival
ユーザー mmn15277198mmn15277198
提出日時 2020-11-17 14:59:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,467 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 102,704 KB
実行使用メモリ 13,272 KB
最終ジャッジ日時 2023-09-30 14:14:24
合計ジャッジ時間 3,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 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,380 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 9 ms
4,380 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 37 ms
11,576 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 9 ms
4,380 KB
testcase_21 AC 18 ms
5,268 KB
testcase_22 AC 12 ms
5,204 KB
testcase_23 AC 13 ms
5,268 KB
testcase_24 AC 66 ms
13,148 KB
testcase_25 AC 67 ms
13,084 KB
testcase_26 AC 66 ms
11,388 KB
testcase_27 AC 67 ms
13,272 KB
testcase_28 AC 66 ms
11,416 KB
testcase_29 AC 66 ms
11,616 KB
testcase_30 AC 67 ms
13,208 KB
testcase_31 AC 65 ms
12,008 KB
testcase_32 AC 65 ms
11,796 KB
testcase_33 AC 66 ms
11,812 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>
#include<set>

#define rep(i,n) for(int (i) = 0; i < (n); i++)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

//const ll mod = 1e9 + 7;
const ll mod = 998244353;
const int inf = 123456;
const int siz = 202020;

ll dist(int a , int b , int c , int d){
    return (ll)(a - b)*(a - b) + (ll)(c - d)*(c - d);
}

int main() {
        int n;
        cin >> n;
        vector<int> x(n) , y(n);
        for(int i = 0; i < n; i++){
            cin >> x[i] >> y[i];
        }
        vector<pair<ll , pair<int , int> > > v;
        for(int i = 0; i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                ll d = dist(x[i] , x[j] , y[i] , y[j]);
                v.push_back(make_pair(d , make_pair(i , j)));
            }
        }
        sort(v.begin() , v.end());
        vector<bool> used(n + 100 , false);
        int ans = 0;
        for(int i = 0; i < v.size(); i++){
            int x = v[i].second.first;
            int y = v[i].second.second;
            if(used[x] == false && used[y] == false){
            	if(x == 0){
            		ans++;
            		used[y] = true;
            	}else{
            		used[x] = used[y] = true;
            	}
            }
        }
        cout << ans << endl;
    return 0;
}
0