Submission #151890

# Submission time Handle Problem Language Result Execution time Memory
151890 2019-09-05T10:07:09 Z Ruxandra985 Computer Network (BOI14_network) C++14
75 / 100
115 ms 4468 KB
#include <cstdio>
#include "network.h"

void findRoute (int n,int a,int b){
    int da[n+1],db[n+1];
    int i,curr,x,y,nxt;
    for (i=1;i<=n;i++){
        da[i] = db[i] = -2;
    }
    curr = a;
    x = -1;
  	da[a] = db[b] = -1;
    da[b] = db[a] = ping(a,b);
    y = da[b];
    while (curr!=b){
 		int more = 0;
        for (i=1;i<=n;i++){
            if (i!=curr){
                if (da[i] == -2)
                    da[i] = ping(a,i);
                if (da[i] == x + 1){
                     if (db[i] == -2)
                         db[i] = ping(i,b);
                    if (y-1 == db[i]){
                        if (!more)
                            nxt = i;
                        else {
                            if (curr == a || ping(curr,nxt)==0)
                              break;
                            else nxt = i;
                        }
                        more = 1;
                    }
                }
            }
        }

        travelTo(nxt);
        curr = nxt;
        x++;
        y--;
    }

}

Compilation message

network.cpp: In function 'void findRoute(int, int, int)':
network.cpp:15:16: warning: 'nxt' may be used uninitialized in this function [-Wmaybe-uninitialized]
     while (curr!=b){
            ~~~~^~~
grader.c: In function 'int main()':
grader.c:48:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d%d%d%d", &N, &a, &b, &M);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
grader.c:51:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &distance[u][v]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 115 ms 4216 KB Output is correct
2 Correct 111 ms 4468 KB Output is correct
3 Correct 102 ms 4216 KB Output is correct
4 Correct 100 ms 4220 KB Output is correct
5 Correct 99 ms 4216 KB Output is correct
6 Correct 99 ms 4232 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 4264 KB Output is correct
2 Correct 27 ms 2300 KB Output is correct
3 Correct 113 ms 4344 KB Output is correct
4 Correct 91 ms 4216 KB Output is correct
5 Correct 113 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 4228 KB Output is correct
2 Correct 26 ms 2296 KB Output is correct
3 Correct 113 ms 4304 KB Output is correct
4 Correct 92 ms 4232 KB Output is correct
5 Correct 113 ms 4336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 4252 KB Too many calls to ping
2 Halted 0 ms 0 KB -