# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741683 | TheOpChicken | Computer Network (BOI14_network) | C++17 | 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 <iostream>
#include <vector>
#include "network.h"
using namespace std;
void findRoute(int n, int a, int b){
vector<vector<int> > dist(n+5, vector<int>());
vector<int> length(n+5);
dist[0].push_back(a);
for (int i = 1; i <= n; i++){
if (i == a) continue;
int len = ping(a, i);
dist[len].push_back(a);
length[i] = len;
}
int cur_node = b;
vector<int> ans;
for (int i = length[b]; i >= 1; i--){
ans.push_back(cur_node);
for (int node: dist[i-1]){
int len = ping(cur_node, node);
if (len == 1){
cur = node;
break;
}
}
}
reverse(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++) travelTo(ans[i]);
return;
}