# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
492557 | vulpes | Countries (BOI06_countries) | C++17 | 5 ms | 336 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;
const int N = 1007;
struct country {
int x, y, s, ind;
} a[N];
bool operator <(country a, country b) {
return (a.s != b.s ? a.s > b.s : a.ind < b.ind);
}
int dist(country x, country y) {
return (x.x - y.x) * (x.x - y.x) +
(x.y - y.y) * (x.y - y.y);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n; cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i].x >> a[i].y >> a[i].s;
a[i].ind = i;
}
sort(a, a + n);
vector<string> ans(n);
for (int i = 0; i < n; i++) {
vector<country> v;
for (int j = 0; j < i; j++) {
if (a[j].s > dist(a[i], a[j]) * a[i].s) {
v.push_back(a[j]);
}
}
if (!v.size()) {
ans[a[i].ind] = "K"; continue;
}
int i1 = 0, i2 = 0, d1, d2;
for (int j = 0; j < v.size(); j++) {
d1 = a[v[i1].ind].s * dist(a[i], v[j]);
d2 = a[v[j].ind].s * dist(a[i], v[i1]);
if (d1 > d2) {
i2 = i1; i1 = j; continue;
}
d1 = a[v[i2].ind].s * dist(a[i], v[j]);
d2 = a[v[j].ind].s * dist(a[i], v[i2]);
if (d1 > d2) {
i2 = j;
}
}
if (i1 != i2) {
ans[a[i].ind] = "D"; continue;
}
if (ans[v[i1].ind] != "K") {
ans[a[i].ind] = ans[v[i1].ind]; continue;
}
ans[a[i].ind] = to_string(v[i1].ind + 1);
}
for (string i : ans) {
cout << i << endl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |