답안 #408831

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
408831 2021-05-19T17:39:50 Z SirCovidThe19th 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int travel_plan(int n, int m, int k, int r[][2], int l[], int p[]){
    vector<vector<pair<int, int>>> adj(n);
    for (int i = 0; i < m; i++){
        adj[r[i][0]].push_back({r[i][1], l[i]});
        adj[r[i][1]].push_back({r[i][0], l[i]});
    }
    priority_queue<pair<long long, int>> trav;
    vector<int> visited(n, 0);
    for (int i = 0; i < k; i++){
        visited[p[i]] = 1;
        trav.push({0, p[i]});
    }
    while (!trav.empty()){
        pair<long long, int> curr = trav.top(); trav.pop();
        visited[curr.second]++;
        if (visited[curr.second] == 2 and curr.second == 0) 
            return -curr.first;
        if (visited[curr.second] == 2){
            visited[curr.second]++;
            for (pair<int, int> elem : adj[curr.second])
                if (visited[elem.second] != 2)
                    trav.push({-(curr.first+elem.second), elem.first});
        }
    }
}



Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int, int (*)[2], int*, int*)':
crocodile.cpp:5:41: warning: control reaches end of non-void function [-Wreturn-type]
    5 |     vector<vector<pair<int, int>>> adj(n);
      |                                         ^
/usr/bin/ld: /tmp/ccNwEdJl.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