結果

問題 No.1265 Balloon Survival
ユーザー ldsybldsyb
提出日時 2020-10-23 22:18:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 207,540 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-28 16:10:22
合計ジャッジ時間 3,765 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using namespace chrono;

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> xs(n), ys(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> xs[i] >> ys[i];
	}

	auto dist = [&](int64_t i, int64_t j) {
		return (xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]);
	};

	int64_t inf = (1LL << 60);

	priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>, greater<>> pq;

	for (int64_t i = 1; i < n; i++)
	{
		pq.emplace(dist(0, i), i);
	}

	vector<bool> rm(n, false);

	int64_t ans = 0;

	while (!pq.empty())
	{
		auto [d, i] = pq.top();
		pq.pop();

		int64_t tmp = inf;
		for (int64_t j = 0; j < n; j++)
		{
			if (i == j)
			{
				continue;
			}

			if (rm[j])
			{
				continue;
			}

			tmp = min(tmp, dist(i, j));
		}

		if (tmp == d)
		{
			ans++;
			rm[i] = true;
		}
	}

	cout << ans << endl;

	return 0;
}
0