# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173487 | Tuk1352 | Countries (BOI06_countries) | C++11 | 11 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |