#include "citymapping.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll inf = 1e15;
void find_roads(int N, int Q, int A[], int B[], int W[]) {
int x = -1;
ll mx = 0;
for (int i = 1; i < N; i++) {
ll s = get_distance(1, i + 1);
if (s > mx) {
mx = s;
x = i;
}
}
vector<pair<ll, int>> p(N);
for (int i = 0; i < N; i++) {
p[i] = {get_distance(x + 1, i + 1), i};
}
sort(p.begin(), p.end());
vector<int> v{x}, cnt(N);
for (int i = 1; i < N; i++) {
int u = p[i].second;
ll mn = inf;
int y = -1;
for (int x : v) {
ll s = get_distance(u + 1, x + 1);
if (s < mn) {
mn = s;
y = x;
}
}
A[i - 1] = u + 1;
B[i - 1] = y + 1;
W[i - 1] = mn;
cnt[u]++;
if (++cnt[y] == 3) {
v.erase(find(v.begin(), v.end(), y));
}
v.push_back(u);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
468 KB |
Too many calls to get_distance(). |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
468 KB |
Too many calls to get_distance(). |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Too many calls to get_distance(). |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
468 KB |
Too many calls to get_distance(). |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
468 KB |
Too many calls to get_distance(). |
2 |
Halted |
0 ms |
0 KB |
- |