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 "citymapping.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pil = pair<int, long long>;
void find_roads(int N, int Q, int A[], int B[], int W[]) {
const int ROOT = 1;
vector<pil> internal;
for(int u = 1; u <= N; u++) {
internal.emplace_back(u, (u == ROOT) ? 0 : get_distance(ROOT, u));
}
sort(internal.begin(), internal.end(), [&](const pil &p, const pil &q) {
return p.second < q.second;
});
int e = 0;
for(unsigned i = 1; i < internal.size(); i++) {
int u = internal[i].first;
int v = -1; lint d = 1e18;
for(unsigned j = 0; j < i; j++) {
int p = internal[j].first;
lint c = get_distance(u, p);
if(v == -1 || d > c) {
d = c;
v = p;
}
}
A[e] = u; B[e] = v; W[e] = d;
e += 1;
}
}
# | 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... |