#include "citymapping.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ask(int i, int j)
{
return get_distance(i + 1, j + 1);
}
void find_roads(int n, int q, int e_a[], int e_b[], int e_w[])
{
vector<ll> dist0(n, 0);
vector<int> ord;
for (int i = 1; i < n; i++)
{
dist0[i] = ask(0, i);
ord.push_back(i);
}
sort(ord.begin(), ord.end(), [&] (int i, int j) {return dist0[i] < dist0[j];});
vector<int> deja = {0};
int top = 0;
for (auto &vertex : ord)
{
for (int p = (int) deja.size() - 1; p >= 0; p--)
{
int oth = deja[p];
if (ask(oth, vertex) + dist0[oth] == dist0[vertex])
{
e_a[top] = oth + 1;
e_b[top] = vertex + 1;
e_w[top] = dist0[vertex] - dist0[oth];
top++;
break;
}
}
deja.push_back(vertex);
}
if (0)
{
for (int i = 0; i < top; i++)
{
cout << " : " << e_a[i] << " " << e_b[i] << " " << e_w[i] << "\n";
}
}
assert(top == n - 1);
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 2917 out of 500000 queries used. |
2 |
Correct |
2 ms |
460 KB |
Correct: 3403 out of 500000 queries used. |
3 |
Correct |
5 ms |
464 KB |
Correct: 68207 out of 500000 queries used. |
4 |
Correct |
6 ms |
468 KB |
Correct: 117026 out of 500000 queries used. |
5 |
Correct |
3 ms |
460 KB |
Correct: 20830 out of 500000 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 2917 out of 500000 queries used. |
2 |
Correct |
2 ms |
460 KB |
Correct: 3403 out of 500000 queries used. |
3 |
Correct |
5 ms |
464 KB |
Correct: 68207 out of 500000 queries used. |
4 |
Correct |
6 ms |
468 KB |
Correct: 117026 out of 500000 queries used. |
5 |
Correct |
3 ms |
460 KB |
Correct: 20830 out of 500000 queries used. |
6 |
Correct |
1 ms |
468 KB |
Correct: 2018 out of 500000 queries used. |
7 |
Correct |
11 ms |
500 KB |
Correct: 129256 out of 500000 queries used. |
8 |
Correct |
5 ms |
468 KB |
Correct: 68451 out of 500000 queries used. |
9 |
Correct |
8 ms |
464 KB |
Correct: 123223 out of 500000 queries used. |
10 |
Correct |
2 ms |
460 KB |
Correct: 18028 out of 500000 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 2121 out of 12000 queries used. |
2 |
Correct |
1 ms |
468 KB |
Correct: 2424 out of 12000 queries used. |
3 |
Correct |
1 ms |
468 KB |
Correct: 2629 out of 12000 queries used. |
4 |
Correct |
1 ms |
468 KB |
Correct: 2618 out of 12000 queries used. |
5 |
Correct |
1 ms |
468 KB |
Correct: 2326 out of 12000 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 2121 out of 12000 queries used. |
2 |
Correct |
1 ms |
468 KB |
Correct: 2424 out of 12000 queries used. |
3 |
Correct |
1 ms |
468 KB |
Correct: 2629 out of 12000 queries used. |
4 |
Correct |
1 ms |
468 KB |
Correct: 2618 out of 12000 queries used. |
5 |
Correct |
1 ms |
468 KB |
Correct: 2326 out of 12000 queries used. |
6 |
Correct |
2 ms |
468 KB |
Correct: 2919 out of 12000 queries used. |
7 |
Correct |
1 ms |
468 KB |
Correct: 2755 out of 12000 queries used. |
8 |
Correct |
1 ms |
468 KB |
Correct: 2384 out of 12000 queries used. |
9 |
Correct |
1 ms |
468 KB |
Correct: 2443 out of 12000 queries used. |
10 |
Correct |
1 ms |
468 KB |
Correct: 2618 out of 12000 queries used. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Correct: 2917 out of 500000 queries used. |
2 |
Correct |
2 ms |
460 KB |
Correct: 3403 out of 500000 queries used. |
3 |
Correct |
5 ms |
464 KB |
Correct: 68207 out of 500000 queries used. |
4 |
Correct |
6 ms |
468 KB |
Correct: 117026 out of 500000 queries used. |
5 |
Correct |
3 ms |
460 KB |
Correct: 20830 out of 500000 queries used. |
6 |
Correct |
1 ms |
468 KB |
Correct: 2018 out of 500000 queries used. |
7 |
Correct |
11 ms |
500 KB |
Correct: 129256 out of 500000 queries used. |
8 |
Correct |
5 ms |
468 KB |
Correct: 68451 out of 500000 queries used. |
9 |
Correct |
8 ms |
464 KB |
Correct: 123223 out of 500000 queries used. |
10 |
Correct |
2 ms |
460 KB |
Correct: 18028 out of 500000 queries used. |
11 |
Correct |
1 ms |
468 KB |
Correct: 2121 out of 12000 queries used. |
12 |
Correct |
1 ms |
468 KB |
Correct: 2424 out of 12000 queries used. |
13 |
Correct |
1 ms |
468 KB |
Correct: 2629 out of 12000 queries used. |
14 |
Correct |
1 ms |
468 KB |
Correct: 2618 out of 12000 queries used. |
15 |
Correct |
1 ms |
468 KB |
Correct: 2326 out of 12000 queries used. |
16 |
Correct |
2 ms |
468 KB |
Correct: 2919 out of 12000 queries used. |
17 |
Correct |
1 ms |
468 KB |
Correct: 2755 out of 12000 queries used. |
18 |
Correct |
1 ms |
468 KB |
Correct: 2384 out of 12000 queries used. |
19 |
Correct |
1 ms |
468 KB |
Correct: 2443 out of 12000 queries used. |
20 |
Correct |
1 ms |
468 KB |
Correct: 2618 out of 12000 queries used. |
21 |
Correct |
1 ms |
472 KB |
Correct: 2945 out of 25000 queries used. |
22 |
Incorrect |
3 ms |
468 KB |
Too many calls to get_distance(). |
23 |
Halted |
0 ms |
0 KB |
- |