# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16044 | kaTkaHr | Computer Network (BOI14_network) | C++98 | 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 "network.h"
#include<vector>
using namespace std;
const int MX = 1005;
vector<int> G[MX];
void findRoute (int N, int a, int b)
{
int D = ping(a, b) + 1;
for (int i = 1; i <= N; i++){
if (i == b) G[0].push_back(b);
else if( i != a ) G[ping(b, i) + 1].push_back(i);
else G[D].push_back(i);
}
int nw = a;
for (int i = 1;; i++){
int nxt = -1;
for (int c : G[D-i]){
if (ping(nw, c) == 0){
nxt = c;
if (nxt == b){
travelTo(nxt);
return;
}
}
}
nw = nxt;
travelTo(nxt);
}
}