# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462609 | JovanB | Countries (BOI06_countries) | C++17 | 5 ms | 384 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;
typedef long long ll;
typedef long double ld;
int par[100005];
int x[100005];
int y[100005];
int s[100005];
struct broj{
int p, q;
bool operator <(const broj & a) const{
return p * a.q < a.p * q;
}
bool operator ==(const broj & a) const{
return p * a.q == a.p * q;
}
};
int dist(int j, int i){
return (x[j]-x[i])*(x[j]-x[i]) + (y[j]-y[i])*(y[j]-y[i]);
}
broj infl(int j, int i){
return {s[j], dist(j, i)};
}
int root(int a){
if(par[a] == a) return a;
return root(par[a]);
}
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
int n;
cin >> n;
for(int i=1; i<=n; i++){
cin >> x[i] >> y[i] >> s[i];
}
for(int i=1; i<=n; i++){
broj mx;
mx.q = 0;
for(int j=1; j<=n; j++){
if(i == j) continue;
if(mx.q == 0) mx = infl(j, i);
else if(mx < infl(j, i)) mx = infl(j, i);
}
if(mx.p <= s[i]*mx.q){
par[i] = i;
continue;
}
for(int j=1; j<=n; j++){
if(j == i) continue;
if(mx == infl(j, i)){
if(!par[i]) par[i] = j;
else par[i] = -1;
}
}
}
for(int i=1; i<=n; i++){
if(par[i] == i) cout << "K\n";
else if(par[i] == -1) cout << "D\n";
else cout << root(i) << "\n";
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |