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 ll = long long;
const int N = 1010;
ll dis[N][N];
int n;
ll d(int i, int j) {
if (i == j) return 0;
if (!dis[i][j]) return dis[i][j] = dis[j][i] = get_distance(i, j);
return dis[i][j];
}
void find_roads(int NN, int Q, int A[], int B[], int W[]) {
n = NN;
int mx = 0, idx = 0;
for (int i = 2;i <= n;i++) {
if (d(1, i) > mx) {
mx = d(1, i);
idx = i;
}
}
vector<pair<ll, int>> v;
for (int i = 1;i <= n;i++) {
v.push_back({ d(idx, i), i });
}
sort(v.begin(), v.end());
for (int i = 1;i < n;i++) {
A[i - 1] = v[i - 1].second;
B[i - 1] = v[i].second;
W[i - 1] = v[i].first - v[i - 1].first;
}
return;
}
# | 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... |