Submission #34547

# Submission time Handle Problem Language Result Execution time Memory
34547 2017-11-12T10:14:50 Z Extazy Computer Network (BOI14_network) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "network.h"

#define endl '\n'

using namespace std;

const int N = 1024;

int n,a,b;
int da[N],db[N];
int min_dist;
int shortest,path[N],path_sz;

/*void travelTo(int x) {
}

int ping(int a, int b) {
    
}*/

int ask(int a, int b) {
    if(a==b) return 0;
    return 1+ping(a,b);
}

bool cmp(int a, int b) {
    return da[a]<da[b];
}

int findRoute(int N, int A, int B) {
    int i;
    
    n=N;
    a=A;
    b=B;

    shortest=ask(a,b);
    da[a]=0;
    da[b]=shortest;
    db[a]=shortest;
    db[b]=0;
    path_sz=0;

    for(i=1;i<=n;i++) if(i!=A && i!=B) {
        da[i]=ask(a,i);
        db[i]=ask(b,i);
        if(da[i]+db[i]==shortest) path[++path_sz]=i;
    }

    sort(path+1,path+1+path_sz,cmp);
    for(i=1;i<=path_sz;i++) travelTo(path[i]);
    travelTo(b);
}

/*int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    return 0;
}*/

Compilation message

network.cpp: In function 'int findRoute(int, int, int)':
network.cpp:31:34: error: ambiguating new declaration of 'int findRoute(int, int, int)'
 int findRoute(int N, int A, int B) {
                                  ^
In file included from network.cpp:2:0:
network.h:1:6: note: old declaration 'void findRoute(int, int, int)'
 void findRoute(int N, int a, int b);
      ^
network.cpp:54:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
grader.c: In function 'int main()':
grader.c:48:39: 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:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &distance[u][v]);
                                         ^