Submission #374331

#TimeUsernameProblemLanguageResultExecution timeMemory
374331topovikOdašiljači (COCI20_odasiljaci)C++14
70 / 70
264 ms33356 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const ll N = 1e6 + 100; const ll oo = 1e9 + 7; int pred[N], r[N]; ld dist(ld x, ld y, ld x1, ld y1) { return sqrt(pow(x - x1, 2) + pow(y - y1, 2)); } int cmp(int x) { if (x == pred[x]) return x; else return pred[x] = cmp(pred[x]); } void unite(int x, int y) { if (r[x] > r[y]) pred[y] = x; else { pred[x] = y; r[y] += (r[x] == r[y]); } } int main() { int n; cin >> n; ld x[n], y[n]; for (int i = 0; i < n; i++) cin >> x[i] >> y[i]; vector <pair<ld, pair<int, int> > > qur; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) qur.pb({dist(x[i], y[i], x[j], y[j]), {i, j}}); for (int i = 0; i < n; i++) pred[i] = i, r[i] = 0; sort(qur.begin(), qur.end()); int cn = 0; cout << setprecision(7) << fixed; for (int i = 0; i < qur.size(); i++) { int x = qur[i].s.f, y = qur[i].s.s; if (cmp(x) != cmp(y)) { cn++; unite(cmp(x), cmp(y)); if (cn == n - 1) { cout << (qur[i].f / (ld)2) << endl; return 0; } } } }

Compilation message (stderr)

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < qur.size(); i++)
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...