# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729317 | Karpin | Countries (BOI06_countries) | C++14 | 4 ms | 340 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 ll long long
#define vt vector
#define ar array
struct city {
int x;
int y;
double s;
};
struct resCondition{
double threatenPower;
int leaderCountry;
bool isDemocracy;
};
int getDist (city first, city second){
return (second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y);
}
double getStrength (city first, city enemy){
return first.s / getDist(first, enemy);
}
void solve(){
int n;
cin >> n;
vt<city> cities;
for(int i = 0; i < n; i++){
int a, b;
double c;
cin >> a >> b >> c;
city my = {a, b, c};
cities.push_back(my);
}
vt<resCondition> res;
for(int i = 0; i < n; i++) {
res.push_back({0, i, false});
}
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++){
if (getStrength(cities[i], cities[j]) > cities[j].s){
if (getStrength(cities[i], cities[j]) > res[j].threatenPower){
res[j].threatenPower = getStrength(cities[i], cities[j]);
res[j].leaderCountry = i;
res[j].isDemocracy = false;
}else if (getStrength(cities[i], cities[j]) == res[j].threatenPower){
res[j].isDemocracy = true;
}
}
if (cities[i].s < getStrength(cities[j], cities[i])){
if (res[i].threatenPower < getStrength(cities[j], cities[i])){
res[i].threatenPower = getStrength(cities[j], cities[i]);
res[i].leaderCountry = j;
res[i].isDemocracy = false;
} else if (res[i].threatenPower == getStrength(cities[j], cities[i])){
res[i].isDemocracy = true;
}
}
}
}
for(int i = 0; i < n; i++){
if (res[i].isDemocracy) cout << 'D' << endl;
else if (res[i].leaderCountry == i) cout << 'K' << endl;
else{
int pointer = i;
while (res[pointer].leaderCountry != pointer) pointer = res[pointer].leaderCountry;
cout << pointer + 1 << endl;
}
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int testcases = 1;
// cin >> testcases;
while(testcases--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |