# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729696 | thimote75 | Countries (BOI06_countries) | C++14 | 4 ms | 368 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 num long long
struct Influence {
num dx, dy, sj, from;
Influence () {
dx = 0;
dy = 0;
sj = 0;
from = -2;
}
Influence (num dx, num dy, num sj, num from) : dx(dx), dy(dy), sj(sj), from(from) {}
bool valid (num si) {
return sj > si * dist();
}
num dist () {
return dx * dx + dy * dy;
}
void merge (num si, Influence &other) {
if (!other.valid(si)) return ;
num idel = dist() * other.sj - sj * other.dist();
if (from == -2) {
dx = other.dx;
dy = other.dy;
sj = other.sj;
from = other.from;
} else if (idel == 0) {
from = -1;
} else if (idel > 0) {
dx = other.dx;
dy = other.dy;
sj = other.sj;
from = other.from;
}
}
void show () {
if (from == -2) cout << "K";
else if (from == -1) cout << "D";
else cout << from + 1;
cout << " ";
}
};
vector<int> x;
vector<int> y;
vector<int> s;
vector<Influence> i;
int main () {
int N;
cin >> N;
x.resize(N);
y.resize(N);
s.resize(N);
i.resize(N);
priority_queue<pair<int, int>> p;
for (int j = 0; j < N; j ++) {
cin >> x[j] >> y[j] >> s[j];
p.push({ s[j], j });
}
for (int iu = 0; iu < N; iu ++) {
auto mu = p.top(); p.pop();
int u = mu.second;
for (int v = 0; v < N; v ++) {
if (u == v) continue ;
Influence i_uv (x[v] - x[u], y[v] - y[u], s[u], i[u].from < 0 ? u : i[u].from);
i[v].merge(s[v], i_uv);
}
}
for (Influence i_u : i) i_u.show();
cout << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |