# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
206680 | PeppaPig | Computer Network (BOI14_network) | C++14 | 143 ms | 4728 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 <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 1e3+5;
map<pii, int> mp;
int get_dist(int a, int b) {
if(a == b) return 0;
else if(mp.count(pii(a, b))) return mp[pii(a, b)];
else return mp[pii(a, b)] = mp[pii(b, a)] = ping(a, b) + 1;
}
int len;
vector<int> dist[N];
void findRoute (int n, int a, int b) {
for(int i = 1; i <= n; i++) if(i != a) {
int now = get_dist(a, i);
dist[now].emplace_back(i);
if(i == b) len = now;
}
int pre = a;
for(int i = 1; i < len; i++) for(int x : dist[i])
if(get_dist(pre, x) == 1 && i + get_dist(x, b) == len) {
travelTo(x);
pre = x;
break;
}
travelTo(b);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |