# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199457 | TadijaSebez | Countries (BOI06_countries) | C++11 | 10 ms | 428 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;
#define ldb long double
#define ll long long
const int N=1005;
int x[N],y[N],s[N],id[N];
int my[N];
ll sq(ll x, ll y){ return x*x+y*y;}
ll dist(int i, int j){ return sq(x[i]-x[j],y[i]-y[j]);}
bool d[N];
int main()
{
int n;
scanf("%i",&n);
for(int i=1;i<=n;i++) scanf("%i %i %i",&x[i],&y[i],&s[i]),id[i]=i;
sort(id+1,id+1+n,[&](int i, int j){ return s[i]>s[j];});
for(int j=1;j<=n;j++)
{
int i=id[j];
ldb mx=0;
int cnt=0,cap=-1;
for(int k=1;k<=n;k++) if(k!=i)
{
ldb tmp=(ldb)s[k]/dist(i,k);
if(tmp>s[i])
{
if(mx<tmp) mx=tmp,cnt=0;
if(mx==tmp) cnt++,cap=my[k];
}
}
if(cnt==0) my[i]=i;
else if(cnt==1) my[i]=cap;
else my[i]=i,d[i]=1;
}
for(int i=1;i<=n;i++)
{
if(my[i]==i)
{
if(d[i]) printf("D\n");
else printf("K\n");
}
else printf("%i\n",my[i]);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |