Submission #151888

# Submission time Handle Problem Language Result Execution time Memory
151888 2019-09-05T10:05:40 Z Ruxandra985 Computer Network (BOI14_network) C++14
0 / 100
113 ms 4316 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[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 (i == b)
                        db[i] = -1;
                    else {
                        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:14: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 Incorrect 113 ms 4316 KB ping called with invalid arguments
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 4216 KB ping called with invalid arguments
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 4312 KB ping called with invalid arguments
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 4216 KB ping called with invalid arguments
2 Halted 0 ms 0 KB -