Submission #356497

#TimeUsernameProblemLanguageResultExecution timeMemory
356497ivanppOdašiljači (COCI20_odasiljaci)C++14
70 / 70
79 ms8664 KiB
#include <bits/stdc++.h> using namespace std; int n; int x[1005], y[1005]; int daddy[1005]; double ud(double x1, double x2, double y1, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int find(int a) { if (daddy[a] == a) return daddy[a]; return daddy[a] = find(daddy[a]); } bool junion(int x, int y) { x = find(x); y = find(y); if (x != y) { daddy[x] = y; return true; } return false; } int main() { cin >> n; vector < pair < double, pair <int, int> > > uds; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; for (int j = 0; j < i; j++) { uds.push_back({ud(x[j], x[i], y[j], y[i]), {i, j}}); } } for (int i = 0; i < n; i++) { daddy[i] = i; } sort(uds.begin(), uds.end()); double ans = 0.0; for (int i = 0; i < uds.size(); i++) { int xx = uds[i].second.first; int yy = uds[i].second.second; if (junion(xx, yy)) { ans = uds[i].first / 2; } } printf("%.9f \n", ans); return 0; }

Compilation message (stderr)

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:54: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]
   54 |  for (int i = 0; i < uds.size(); i++) {
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...