結果

問題 No.1265 Balloon Survival
ユーザー shinchanshinchan
提出日時 2020-10-23 22:17:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,376 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 2,564 ms
コンパイル使用メモリ 207,208 KB
実行使用メモリ 66,076 KB
最終ジャッジ日時 2023-09-28 16:09:35
合計ジャッジ時間 18,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 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,380 KB
testcase_14 AC 69 ms
10,936 KB
testcase_15 AC 45 ms
8,968 KB
testcase_16 AC 13 ms
5,484 KB
testcase_17 AC 569 ms
36,480 KB
testcase_18 AC 21 ms
6,536 KB
testcase_19 AC 15 ms
5,904 KB
testcase_20 AC 64 ms
10,876 KB
testcase_21 AC 200 ms
19,808 KB
testcase_22 AC 102 ms
13,376 KB
testcase_23 AC 116 ms
14,584 KB
testcase_24 AC 1,376 ms
65,840 KB
testcase_25 AC 1,348 ms
65,812 KB
testcase_26 AC 1,344 ms
65,860 KB
testcase_27 AC 1,352 ms
65,868 KB
testcase_28 AC 1,372 ms
65,844 KB
testcase_29 AC 1,354 ms
66,076 KB
testcase_30 AC 1,342 ms
65,864 KB
testcase_31 AC 1,351 ms
65,836 KB
testcase_32 AC 1,357 ms
65,968 KB
testcase_33 AC 1,365 ms
65,840 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll calc(ll x, ll y){return x*x + y*y;}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n;
    bool burst[n];
    memset(burst, 0, sizeof(burst));
    vector<pair<ll, ll> > v;
    multiset<pair<ll, pair<int, int> > > ms;
    for(int i=0;i<n;i++){
    	cin >> a >> b;
    	v.push_back({a, b});
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		if(i == j) continue;
    		ms.insert({calc(v[i].first - v[j].first, v[i].second - v[j].second), {i, j}});
    	}
    }
    int ans = 0;
    while(!ms.empty()){

    	auto itr = ms.begin();
    	int id1 = itr->second.first;
    	int id2 = itr->second.second;
    	ms.erase(itr);
    	if(burst[id1] || burst[id2]) continue;
    	if(id1 > id2) swap(id1, id2);
    	if(id1 == 0){
    		burst[id2] = true;
    		ans++;
    	}else{
    		burst[id1] = burst[id2] = true;
    	}
    }
    cout << ans << endl;
    return 0;
}
0