結果

問題 No.1265 Balloon Survival
ユーザー leaf_1415leaf_1415
提出日時 2020-10-23 22:11:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 1,252 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 80,232 KB
実行使用メモリ 16,980 KB
最終ジャッジ日時 2023-09-28 15:58:53
合計ジャッジ時間 4,287 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 14 ms
4,780 KB
testcase_15 AC 11 ms
4,760 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 69 ms
16,980 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 14 ms
4,680 KB
testcase_21 AC 30 ms
6,220 KB
testcase_22 AC 19 ms
6,972 KB
testcase_23 AC 21 ms
6,148 KB
testcase_24 AC 146 ms
16,228 KB
testcase_25 AC 151 ms
16,616 KB
testcase_26 AC 153 ms
16,532 KB
testcase_27 AC 147 ms
15,596 KB
testcase_28 AC 152 ms
16,376 KB
testcase_29 AC 149 ms
16,640 KB
testcase_30 AC 151 ms
16,460 KB
testcase_31 AC 152 ms
16,484 KB
testcase_32 AC 154 ms
15,660 KB
testcase_33 AC 151 ms
15,900 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define all(x) (x).begin(),(x).end()
#define inf 1e18

using namespace std;

typedef long long llint;
typedef pair<llint, llint> P;
typedef pair<llint, P> T;

llint n;
priority_queue<T, vector<T>, greater<T> > Q;
llint x[1005], y[1005];
bool used[1005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			Q.push(T((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]), P(i, j)));
		}
	}
	
	llint ans = 0;
	while(Q.size()){
		llint x = Q.top().second.first, y = Q.top().second.second;
		Q.pop();
		if(used[x] || used[y]) continue;
		if(x == 1 || y == 1) ans++;
		if(x != 1) used[x] = true;
		if(y != 1) used[y] = true;
	}
	cout << ans << endl;
	
	return 0;
}
0