답안 #127630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127630 2019-07-09T17:51:47 Z dolphingarlic 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MOD 1000000007
#define MAXN 100001
using namespace std;

vector<int> exits;
vector<pair<int, int>> graph[MAXN];
int visited[MAXN];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    FOR(i, 0, M) {
        graph[R[i][0]].push_back({graph[R[i][1]], L[i]});
        graph[R[i][1]].push_back({graph[R[i][0]], L[i]});
    }
    FOR(i, 0, K)
    exits.push_back(P[i]);
    fill(visited, visited + MAXN, 0);
    priority_queue<pair<int, int>> pq;  // Distance from an exit
    for (int i : exits) {
        pq.push({0, i});
        visited[i] = 1;
    }

    while (!pq.empty()) {
        int curr_node = pq.top().second, curr_cost = pq.top().first;
        pq.pop();

        if (visited[curr_node] == 0) {
            visited[curr_node]++;
        } else if (visited[curr_node] == 1) {
            if (curr_node == 0) return -curr_cost;
            visited[curr_node]++;
            for (pair<int, int> i : graph[curr_node]) pq.push({curr_cost - i.second, i.first});
        }
    }
}

Compilation message

crocodile.cpp:3:0: warning: ignoring #pragma GCC Optimize [-Wunknown-pragmas]
 #pragma GCC Optimize("O3")
 
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:15:56: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
         graph[R[i][0]].push_back({graph[R[i][1]], L[i]});
                                                        ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
crocodile.cpp:16:56: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
         graph[R[i][1]].push_back({graph[R[i][0]], L[i]});
                                                        ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<int, int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&& {aka std::pair<int, int>&&}'
crocodile.cpp:39:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^