#include "citymapping.h"
#define ff first
#define ss second
#define ALL(x) x.begin(),x.end()
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
using ll = long long;
using PII = pair <ll, int>;
ll get(int a, int b) {
// cout << "ASK: " << a << ' ' << b << '\n';
ll x = get_distance(a, b);
return x;
}
int pt = 0;
vector <vector <int> > ans;
void find_roads(int n, int q, int a[], int b[], int w[]) {
PII edge;
edge = {0, 0};
for (int i = 2; i <= n; i++) {
ll x = get(1, i);
if (edge.ff < x) edge = {x, i};
}
vector <PII> vals;
int ed = edge.ss;
for (int i = 1; i <= n; i++) {
if (i == edge.ss) continue;
ll x = get(ed, i);
vals.pb({x, i});
}
sort(ALL(vals));
ans.pb({ed, vals[0].ss, (int)vals[0].ff});
for (int i = 0; i+1 < vals.size(); i++) {
ans.pb({vals[i].ss, vals[i+1].ss, (int)(vals[i+1].ff - vals[i].ff)});
}
for (auto el : ans) {
int x = el[0], y = el[1], z = el[2];
a[pt] = x;
b[pt] = y;
w[pt] = z;
pt++;
}
}
/*
5 100000000 5
1 4 1
2 4 1
3 4 1
3 5 1
*/
Compilation message
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i+1 < vals.size(); i++) {
| ~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 1996 out of 500000 queries used. |
2 |
Incorrect |
1 ms |
468 KB |
Reported list of edges differ from actual. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 1996 out of 500000 queries used. |
2 |
Incorrect |
1 ms |
468 KB |
Reported list of edges differ from actual. |
3 |
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 |
1 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 |
1 ms |
468 KB |
Correct: 1980 out of 12000 queries used. |
6 |
Correct |
1 ms |
468 KB |
Correct: 1994 out of 12000 queries used. |
7 |
Correct |
2 ms |
516 KB |
Correct: 1990 out of 12000 queries used. |
8 |
Correct |
2 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 |
2 ms |
524 KB |
Correct: 1986 out of 12000 queries used. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 1996 out of 500000 queries used. |
2 |
Incorrect |
1 ms |
468 KB |
Reported list of edges differ from actual. |
3 |
Halted |
0 ms |
0 KB |
- |