#include "network.h"
#include <algorithm>
using namespace std;
int d[2005], c[2005];
void findRoute(int N, int a, int b) {
int dist = ping(a, b);
for (int i = 1; i <= N; i++) d[i] = c[i] = 0;
for (int i = 1; i <= N; i++) if (i != a) c[i] = d[i] = ping(a, i) + 1;
sort(c + 1, c + N + 1);
bool ok = 1;
for (int i = 2; i <= N; i++) if (c[i] - c[i - 1] != 1) ok = 0;
if (ok) {
for (int i = 1; i <= dist; i++) {
for (int j = 1; j <= N; j++) {
if (d[j] - d[a] == 1) {
int v = ping(j, b);
if (dist == v + d[a] + 1) {
a = j;
travelTo(j);
break;
}
}
}
}
travelTo(b);
}
else {
for (int i = 1; i <= dist; i++) {
for (int j = 1; j <= N; j++) {
if (d[j] - d[a] == 1) {
int v = ping(j, b);
if (dist == v + d[a] + 1 && ping(a, j) == 0) {
a = j;
travelTo(j);
break;
}
}
}
}
travelTo(b);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
128 ms |
5084 KB |
Output is correct |
2 |
Correct |
115 ms |
5084 KB |
Output is correct |
3 |
Correct |
156 ms |
5084 KB |
Output is correct |
4 |
Correct |
74 ms |
5084 KB |
Output is correct |
5 |
Correct |
105 ms |
5084 KB |
Output is correct |
6 |
Correct |
88 ms |
5084 KB |
Output is correct |
7 |
Correct |
0 ms |
5084 KB |
Output is correct |
8 |
Correct |
0 ms |
5084 KB |
Output is correct |
9 |
Correct |
0 ms |
5084 KB |
Output is correct |
10 |
Correct |
0 ms |
5084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
5084 KB |
Output is correct |
2 |
Correct |
21 ms |
5084 KB |
Output is correct |
3 |
Correct |
111 ms |
5084 KB |
Output is correct |
4 |
Correct |
99 ms |
5084 KB |
Output is correct |
5 |
Correct |
135 ms |
5084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
5084 KB |
Output is correct |
2 |
Correct |
25 ms |
5084 KB |
Output is correct |
3 |
Correct |
83 ms |
5084 KB |
Output is correct |
4 |
Correct |
102 ms |
5084 KB |
Output is correct |
5 |
Correct |
128 ms |
5084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
112 ms |
5084 KB |
Output isn't correct - Too many calls to ping |
2 |
Halted |
0 ms |
0 KB |
- |