#include "network.h"
#define N 1000
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int ii[N], dd[N];
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k)
if (dd[ii[j]] == dd[i_])
j++;
else if (dd[ii[j]] < dd[i_]) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
sort(ii, l, i);
l = k;
}
}
void findRoute(int n, int s, int t) {
int h, i;
s--, t--;
for (i = 0; i < n; i++)
dd[i] = i == t ? 0 : ping(i + 1, t + 1) + 1;
for (i = 0; i < n; i++)
ii[i] = i;
sort(ii, 0, n);
for (h = n - 1; h >= 0; h--) {
i = ii[h];
if (dd[i] == dd[s] - 1 && ping(s + 1, i + 1) == 0)
travelTo((s = i) + 1);
}
}
Compilation message
grader.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.