# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88734 | popovicirobert | Computer Network (BOI14_network) | C++14 | 122 ms | 59024 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 <bits/stdc++.h>
#include "network.h"
/*static const int MAX_N = 1010;
static int N, a, b, M,
pingCount,
routeLength, current;
static int distance[MAX_N][MAX_N];
static void raiseError (const char* message)
{
printf ("ERROR\n%s\n", message);
exit (0);
}
int ping (int i, int j)
{
if (i < 1 || j < 1 || i > N || j > N || i == j)
raiseError ("ping called with invalid arguments");
++pingCount;
if (pingCount > M)
raiseError ("Too many calls to ping");
return distance[i-1][j-1];
}
void travelTo (int k)
{
if (k < 1 || k > N)
raiseError ("travelTo called with invalid argument");
if (k == current || distance[current-1][k-1] > 0)
raiseError ("Travelling to nonadjacent computer");
++routeLength;
if (routeLength > distance[a-1][b-1] + 1)
raiseError ("Route is too long");
current = k;
}*/
const int MAXN = 1000;
int distB[MAXN + 1];
bool distA[MAXN + 1];
void findRoute(int N, int a, int b) {
int i;
for(i = 1; i <= N; i++) {
if(i != b)
distB[i] = ping(b, i) + 1;
}
distA[a] = 1;
int d = distB[a];
while(d > 0) {
d--;
for(i = 1; i <= N; i++) {
if(distA[i] == 0 && distB[i] + 1 == distB[a]) {
if(ping(a, i) + 1 == 1) {
a = i;
travelTo(a);
break;
}
distA[i] = 1;
}
}
}
}
/*int main()
{
scanf ("%d%d%d%d", &N, &a, &b, &M);
for (int u = 0; u < N; ++u)
for (int v = 0; v < N; ++v)
scanf("%d", &distance[u][v]);
pingCount = 0;
routeLength = 0;
current = a;
findRoute (N, a, b);
if (current != b)
raiseError ("Message has not reached its target");
if (routeLength < distance[a-1][b-1] + 1)
raiseError ("Unexpected: route is too short");
printf ("OK\n");
return 0;
}*/
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... |