結果

問題 No.1265 Balloon Survival
ユーザー Example0911Example0911
提出日時 2020-10-23 22:29:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 980 bytes
コンパイル時間 3,810 ms
コンパイル使用メモリ 209,780 KB
実行使用メモリ 12,972 KB
最終ジャッジ日時 2023-09-28 16:35:09
合計ジャッジ時間 4,495 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 37 ms
11,232 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 18 ms
5,176 KB
testcase_22 AC 12 ms
5,172 KB
testcase_23 AC 13 ms
5,064 KB
testcase_24 AC 67 ms
11,864 KB
testcase_25 AC 67 ms
12,972 KB
testcase_26 AC 68 ms
12,052 KB
testcase_27 AC 67 ms
11,564 KB
testcase_28 AC 66 ms
11,804 KB
testcase_29 AC 67 ms
11,908 KB
testcase_30 AC 67 ms
12,184 KB
testcase_31 AC 66 ms
11,500 KB
testcase_32 AC 66 ms
11,348 KB
testcase_33 AC 67 ms
11,548 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long
ll INF = (1LL << 60);
constexpr int mod = 1000000007;
using P = pair<int, int>;

void solve() {
	int N; cin >> N;
	vector<ll>x(N), y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	vector<pair<ll, P>>p;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			p.push_back({ (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]), {i, j} });
		}
	}
	sort(p.begin(), p.end());
	vector<bool>seen(N);
	ll ans = 0;
	for (int i = 0; i < p.size(); i++) {
		if (!seen[p[i].second.first] && !seen[p[i].second.second]) {
			if (p[i].second.first == 0) {
				ans++;
				seen[p[i].second.second] = true;
			}
			else {
				seen[p[i].second.first] = true;
				seen[p[i].second.second] = true;
			}
		}
	}
	cout << ans << endl;
}
signed main() {
	int t; t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}
0