Submission #151872

# Submission time Handle Problem Language Result Execution time Memory
151872 2019-09-05T08:20:26 Z Ruxandra985 Computer Network (BOI14_network) C++14
25 / 100
117 ms 8164 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,xn,yn,nxt;
    for (i=1;i<=n;i++){
        if (i!=a)
            da[i] = ping (a,i);
        if (i!=b)
            db[i] = ping (b,i);
    }
    curr = a;
    x = -1;
    y = da[b];
    while (curr!=b){

        for (i=1;i<=n;i++){
            if (i!=curr){
                if (i!=b){
                    xn = da[i];
                    yn = db[i];
                }
                else {
                    xn = da[i];
                    yn = -1;
                }
                if (x+1 == xn && y-1 == yn){
                    nxt = i;
                    break;
                }
            }
        }

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

}

Compilation message

network.cpp: In function 'void findRoute(int, int, int)':
network.cpp:16: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 117 ms 8164 KB Output is correct
2 Correct 112 ms 7488 KB Output is correct
3 Correct 102 ms 7032 KB Output is correct
4 Correct 102 ms 7064 KB Output is correct
5 Correct 102 ms 6732 KB Output is correct
6 Correct 103 ms 6628 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 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 6664 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 6676 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 6664 KB Travelling to nonadjacent computer
2 Halted 0 ms 0 KB -