#include "citymapping.h"
#include <bits/stdc++.h>
using namespace std;
void find_roads(int N, int Q, int A[], int B[], int W[]) {
if(Q == 500000){
int p = 0;
for(int i = 0; i < N; i ++){
for(int j = i + 1; j < N; j ++){
int t = get_distance(i+1, j+1);
if(t == 1){
A[p] = i+1;
B[p] = j+1;
W[p++] = 1;
}
}
}
}
else{
vector<pair<long long, long long>> dist(N, {0, 0});
for(int i = 1; i < N; i ++){
dist[i] = {get_distance(1, i + 1), i};
}
sort(dist.rbegin(), dist.rend());
for(int i = 1; i < N; i ++){
dist[i] = {get_distance(dist[i].second + 1, dist[0].second + 1), dist[i].second};
}
long long total = 0;
dist[0] = {0, dist[0].second};
sort(dist.begin(), dist.end());
for(int i = 1; i < N; i ++){
W[i-1] = dist[i].first - total;
A[i-1] = dist[i-1].second + 1;
B[i-1] = dist[i].second + 1;
total += W[i-1];
}
}
return;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
432 KB |
Correct: 498501 out of 500000 queries used. |
2 |
Correct |
34 ms |
452 KB |
Correct: 499500 out of 500000 queries used. |
3 |
Correct |
30 ms |
428 KB |
Correct: 492528 out of 500000 queries used. |
4 |
Correct |
27 ms |
432 KB |
Correct: 494515 out of 500000 queries used. |
5 |
Correct |
35 ms |
416 KB |
Correct: 498501 out of 500000 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
432 KB |
Correct: 498501 out of 500000 queries used. |
2 |
Correct |
34 ms |
452 KB |
Correct: 499500 out of 500000 queries used. |
3 |
Correct |
30 ms |
428 KB |
Correct: 492528 out of 500000 queries used. |
4 |
Correct |
27 ms |
432 KB |
Correct: 494515 out of 500000 queries used. |
5 |
Correct |
35 ms |
416 KB |
Correct: 498501 out of 500000 queries used. |
6 |
Incorrect |
26 ms |
492 KB |
Reported list of edges differ from actual. |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 1980 out of 12000 queries used. |
2 |
Correct |
1 ms |
468 KB |
Correct: 1984 out of 12000 queries used. |
3 |
Correct |
1 ms |
468 KB |
Correct: 1998 out of 12000 queries used. |
4 |
Correct |
2 ms |
468 KB |
Correct: 1984 out of 12000 queries used. |
5 |
Correct |
2 ms |
468 KB |
Correct: 1980 out of 12000 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 1980 out of 12000 queries used. |
2 |
Correct |
1 ms |
468 KB |
Correct: 1984 out of 12000 queries used. |
3 |
Correct |
1 ms |
468 KB |
Correct: 1998 out of 12000 queries used. |
4 |
Correct |
2 ms |
468 KB |
Correct: 1984 out of 12000 queries used. |
5 |
Correct |
2 ms |
468 KB |
Correct: 1980 out of 12000 queries used. |
6 |
Correct |
2 ms |
468 KB |
Correct: 1994 out of 12000 queries used. |
7 |
Correct |
1 ms |
468 KB |
Correct: 1990 out of 12000 queries used. |
8 |
Correct |
1 ms |
468 KB |
Correct: 1998 out of 12000 queries used. |
9 |
Correct |
2 ms |
468 KB |
Correct: 1992 out of 12000 queries used. |
10 |
Correct |
1 ms |
468 KB |
Correct: 1986 out of 12000 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
432 KB |
Correct: 498501 out of 500000 queries used. |
2 |
Correct |
34 ms |
452 KB |
Correct: 499500 out of 500000 queries used. |
3 |
Correct |
30 ms |
428 KB |
Correct: 492528 out of 500000 queries used. |
4 |
Correct |
27 ms |
432 KB |
Correct: 494515 out of 500000 queries used. |
5 |
Correct |
35 ms |
416 KB |
Correct: 498501 out of 500000 queries used. |
6 |
Incorrect |
26 ms |
492 KB |
Reported list of edges differ from actual. |
7 |
Halted |
0 ms |
0 KB |
- |