Submission #173487

#TimeUsernameProblemLanguageResultExecution timeMemory
173487Tuk1352Countries (BOI06_countries)C++11
100 / 100
11 ms504 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, D; 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; D = 1; for (int y = 0; y < n; y++) { if (I != y) { d = ((X[I]-X[y])*(X[I]-X[y])+(Y[I]-Y[y])*(Y[I]-Y[y])); if (s[y]/d > s[I]) { if (s[y]/d > s[Im]/D) { //M = s[y]/d; D = d; k = 1; Im = y; } else if (fabs(s[y]/d-s[Im]/D) <= 0.000000001 && C[y] != Im) { k++; } } } } if (k == 0) { C[I] = I; } else if (k != 1) { 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++)
                     ~~^~~~~~~~~~
countries.cpp:9:38: warning: variable 'M' set but not used [-Wunused-but-set-variable]
     long double X[n], Y[n], s[n], d, M, D;
                                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...