# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
729696 | thimote75 | Countries (BOI06_countries) | C++14 | 4 ms | 368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |