답안 #356545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
356545 2021-01-23T12:54:33 Z fbosnjak Odašiljači (COCI20_odasiljaci) C++14
0 / 70
89 ms 8688 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1000;
int N;
int par[maxn];

double Dist(double a1, double a2, double b1, double b2) {
	return sqrt(pow(a1-b1,2) + pow(a2-b2,2));
}
int Find(int x) {
	return (x == par[x]) ? x : par[x] = Find(par[x]);
}
bool Union(int x, int y) {
	x = par[x];
	y = par[y];
	if (x != y) {par[x] = y; return true;}
	return false;
}

int main() {
	cin >> N;
	double x[N], y[N];
	vector <pair <double, pair <int, int> > > v;
	for (int i = 0; i < N; i++) par[i] = i;

	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		for (int j = 0; j < i; j++) {
			v.push_back({Dist(x[i], y[i], x[j], y[j]), {i, j}});
		}
	}

	sort(v.begin(), v.end());
	double ans = 0.0;

	for (int i = 0; i < v.size(); i++) {
		if (Union(v[i].second.first, v[i].second.second)) ans = v[i].first / 2;
	}

	printf("%.9f \n", ans);
}

Compilation message

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Incorrect 2 ms 364 KB Output isn't correct
5 Incorrect 1 ms 492 KB Output isn't correct
6 Incorrect 22 ms 2528 KB Output isn't correct
7 Incorrect 23 ms 2528 KB Output isn't correct
8 Incorrect 53 ms 8616 KB Output isn't correct
9 Incorrect 80 ms 8688 KB Output isn't correct
10 Incorrect 89 ms 8664 KB Output isn't correct