Submission #173481

#TimeUsernameProblemLanguageResultExecution timeMemory
173481Tuk1352Countries (BOI06_countries)C++11
95 / 100
11 ms376 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, I; cin >> n; long double X[n], Y[n], s[n], d, M; int C[n], Im, k; vector <pair<int,int>> V; for (int i = 0; i < n; i++) { cin >> X[i] >> Y[i] >> s[i]; V.push_back({s[i],i}); } sort(V.rbegin(),V.rend()); for (int i = 0; i < V.size(); i++) { I = V[i].second; Im = I; M = 0; k = 0; for (int y = 0; y < n; y++) { if (I != y) { d = s[y]/((X[I]-X[y])*(X[I]-X[y])+(Y[I]-Y[y])*(Y[I]-Y[y])); if (d > s[I]) { if (d > M) { M = d; k = 1; Im = y; } else if (d == M) { k++; } } } } if (k == 0) { C[I] = I; } else if (k == 2) { C[I] = -1; } else { C[I] = C[Im]; } } for (int i = 0; i < n; i++) { if (C[i] == i) { cout << "K" << "\n"; } else if (C[i] == -1) { cout << "D" << "\n"; } else { cout << C[i]+1 << "\n"; } } return 0; }

Compilation message (stderr)

countries.cpp: In function 'int main()':
countries.cpp:18:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < V.size(); i++)
                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...