Submission #477540

# Submission time Handle Problem Language Result Execution time Memory
477540 2021-10-02T13:47:31 Z RambaXGorilla Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include<cstdio>
#include<climits>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
typedef pair <int,int> ii;
#define pq priority_queue
int travel_plan(int N, int M, int R[][3], int L[], int K, int P[]){
    vector <ii> adj[100010];
    int dists[100010];
    pq <ii, vector <ii>, greater <ii>> least;
    bool once[100010] = {};
    for(int i = 0;i < M;i++){
        adj[R[i][0]].push_back(ii(L[i], R[i][1]));
        adj[R[i][1]].push_back(ii(L[i], R[i][0]));
    }
    fill(dists, dists + 100010, INT_MAX);
    for(int i = 0;i < K;i++){
        least.push(ii(0, P[i]));
        once[P[i]] = true;
    }
    while(!least.empty()){
        int d = least.top().first;
        int u = least.top().second;
        least.pop();
        if(dists[u] != INT_MAX){
            continue;
        }
        if(!once[u]){
            once[u] = true;
            continue;
        }
        if(!u){
            return d;
        }
        dists[u] = d;
        for(int i = 0;i < adj[u].size();i++){
            int e = adj[u][i].first;
            int v = adj[u][i].second;
            least.push(ii(d + e, v));
        }
    }
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[3], int*, int, int*)':
crocodile.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i = 0;i < adj[u].size();i++){
      |                       ~~^~~~~~~~~~~~~~~
crocodile.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
/usr/bin/ld: /tmp/ccflBuGM.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status