# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204083 | ics0503 | Designated Cities (JOI19_designated_cities) | C++17 | 769 ms | 84456 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<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
struct xy { long long x, y, z; };
vector<xy>edge[212121];
long long D[212121], F[212121], FW[212121];
void get_DF(long long w,long long bef) {
D[w] = F[w] = 0; FW[w] = w;
for (xy E : edge[w]) if (E.x != bef) {
get_DF(E.x, w);
D[w] += D[E.x] + E.y;
if (F[w] < F[E.x] + E.z) {
F[w] = F[E.x] + E.z;
FW[w] = FW[E.x];
}
}
}
long long resX[212121], resY[212121], l[212121], r[212121];
void get_res(long long w, long long bef, long long fromRoot) {
long long sum = 0, cnt = 0;
vector<pair<long long, long long>>L;
for (xy E : edge[w]) if (E.x != bef) {
sum += D[E.x] + E.y;
L.push_back({ -(F[E.x] + E.z), FW[E.x] });
}
sort(L.begin(), L.end());
resX[w] = sum + fromRoot;
if (L.size() > 0)resY[w] = -(L[0].first) + sum + fromRoot, l[w] = w, r[w] = L[0].second;
if (L.size() > 1)resY[w] = -(L[0].first + L[1].first) + sum + fromRoot, l[w] = L[0].second, r[w] = L[1].second;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |