Submission #356513

#TimeUsernameProblemLanguageResultExecution timeMemory
356513PotatoOnABusOdašiljači (COCI20_odasiljaci)C++14
70 / 70
88 ms8684 KiB
#include <bits/stdc++.h> #include<iostream> #include<vector> using namespace std; #define FOR(i, a, b) for(int i = (a); i < (b); i++) typedef long long ll; typedef pair<double, double> par; typedef pair<double, pair<int, int>> connec; const int maxn = INT_MAX; vector<par> points; vector<connec> vert; double dist(pair <double, double> x, pair<double, double> y) { return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second)); } vector<int> parovi; int find(int x) { if (x == parovi[x]) return parovi[x]; return parovi[x] = find(parovi[x]); } bool _union(int x, int y) { x = find(x); y = find(y); if (x != y) { parovi[x] = y; return true; } return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; par tmp; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp.first >> tmp.second; points.push_back(tmp); } for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (i == j) continue; connec temp; temp.second.first = i; temp.second.second = j; temp.first = dist(points[i], points[j]); vert.push_back(temp); } } sort(vert.begin(), vert.end()); for (int i = 0; i < n; i++) parovi.push_back(i); double ans = 0.0; for (int i = 0; i < vert.size(); i++) { if (_union(vert[i].second.first, vert[i].second.second)) ans = vert[i].first / 2; } printf("%.9f \n", ans); }

Compilation message (stderr)

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