Submission #356754

#TimeUsernameProblemLanguageResultExecution timeMemory
356754hra_vedOdašiljači (COCI20_odasiljaci)C++17
70 / 70
82 ms8664 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3+1; int par[MAXN]; vector <pair <double, pair <int, int> > > vect; int Find(int x); bool UnionFind(int x, int y); int main() { int N; cin>>N; for (unsigned i = 0; i < N; ++i) par[i] = i; double Xs[N+1], Ys[N+1]; for (unsigned i=0; i<N; ++i) { cin>>Xs[i]>>Ys[i]; for (int j = 0; j < i; j++) { double pit = sqrt( pow((Xs[i]- Xs[j]), 2) + pow((Ys[i]- Ys[j]), 2)) ; vect.push_back(make_pair(pit, make_pair(i, j))); } } sort(vect.begin(), vect.end()); double rj = 0.0; for (unsigned i=0; i<vect.size(); ++i) { if (UnionFind(vect[i].second.first,vect[i].second.second)){ rj = vect[i].first / 2; } } printf("%.9f\n", rj); } int Find(int x) { return (x == par[x]) ? x : par[x] = Find(par[x]); } bool UnionFind(int x, int y) { x = Find(x); y = Find(y); if (x != y) {par[x] = y; return true;} return false; }

Compilation message (stderr)

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:13:28: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   13 |     for (unsigned i = 0; i < N; ++i) par[i] = i;
      |                          ~~^~~
odasiljaci.cpp:15:25: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   15 |     for (unsigned i=0; i<N; ++i) {
      |                        ~^~
odasiljaci.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   17 |         for (int j = 0; j < i; j++) {
      |                         ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...