結果

問題 No.1265 Balloon Survival
ユーザー 沙耶花
提出日時 2020-10-23 22:13:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,005 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 2,489 ms
コンパイル使用メモリ 204,352 KB
最終ジャッジ日時 2025-01-15 13:12:44
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000003

int main(){	
	
	int N;
	cin>>N;
	
	vector<long long> x(N),y(N);
	rep(i,N){
		cin>>x[i]>>y[i];
	}
	
	vector<pair<long long,pair<int,int>>> V;
	
	rep(i,N){
		for(int j=i+1;j<N;j++){
			V.emplace_back((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]),make_pair(i,j));
		}
	}
	
	sort(V.begin(),V.end());
	
	int ans = 0;
	
	while(V.size()!=0){
		vector<pair<long long,pair<int,int>>> nV;
		int a = V[0].second.first,b = V[0].second.second;
		if(a==0){
			ans ++;
			rep(j,V.size()){
				if(V[j].second.first==b||V[j].second.second==b)continue;
				nV.push_back(V[j]);
			}
		}
		else{
			rep(j,V.size()){
				if(V[j].second.first==a||V[j].second.first==b||V[j].second.second==a||V[j].second.second==b)continue;
				nV.push_back(V[j]);
			}
		}
		swap(V,nV);
	}
	
	cout<<ans<<endl;
	
    return 0;
}
0