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<vector>
#include<algorithm>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define x first
#define y second
void find_roads(int N, int Q, int A[], int B[], int W[]) {
ll u = 0, mi = 1;
for (int i = 2; i <= N; i++) {
ll x = get_distance(1, i);
if (x > u) {
u = x;
mi = i;
}
}
vector<pi> vec;
for (int i = 1; i <= N; i++) {
if (i != mi) vec.push_back({ get_distance(mi,i),i });
}
sort(vec.begin(), vec.end());
A[0] = mi; B[0] = vec[0].y; W[0] = vec[0].x;
for (int i = 1; i < N-1; i++) {
A[i] = vec[i].y; B[i] = vec[i - 1].y; W[i] = vec[i].x - vec[i - 1].x;
}
return;
}
/*
5 500000 1
1 4 8
4 2 1
4 3 7
3 5 3
*/
# | 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... |