# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151876 | Ruxandra985 | Computer Network (BOI14_network) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <deque>
#include "network.h"
void findRoute (int n,int a,int b){
int da[n+1],f[n+1],tt[n+1],sol[n+1];
deque <int> dq;
int i,curr,elem;
for (i=1;i<=n;i++){
if (i!=a)
da[i] = ping (a,i);
f[i] = 0;
tt[i] = 0;
}
da[a] = -1;
curr = a;
dq.push_back(a);
f[a] = 1;
while (!dq.empty()){
curr = dq.front();
dq.pop_front();
for (i=1;i<=n;i++){
if (i!=curr && !f[i] && da[i] == da[curr] + 1 && ping(curr,i) == 0){
tt[i] = curr;
f[i] = 1;
dq.push_back(i);
}
}
}
curr = b;
elem = 0;
while (curr){
sol[++elem] = curr;
curr = tt[curr];
}
for (i=elem-1;i;i--)
travelTo(sol[i]);
}