Submission #199457

#TimeUsernameProblemLanguageResultExecution timeMemory
199457TadijaSebezCountries (BOI06_countries)C++11
100 / 100
10 ms428 KiB
#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)

countries.cpp: In function 'int main()':
countries.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
countries.cpp:15:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%i %i %i",&x[i],&y[i],&s[i]),id[i]=i;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...