답안 #851222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851222 2023-09-19T02:10:00 Z NeroZein 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include "crocodile.h"
#include "bits/stdc++.h"
using namespace std; 

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  vector<vector<pair<int, int>>> g(N);
  for (int i = 0; i < M; ++i) {
    g[R[i][0]].emplace_back(R[i][1], L[i]);
    g[R[i][1]].emplace_back(R[i][0], L[i]);
  }
  const int INF = 1e9; 
  vector<vector<int>> dis(N, vector<int> (2, INF)); 
  priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; 
  for (int i = 0; i < K; ++i) {
    dis[P[i]][0] = dis[P[i]][1] = 0;
    pq.emplace(0, P[i]);
  }
  while (!pq.empty()) {
    auto [c, v] = pq.top();
    pq.pop();
    if (c != dis[v][1]) {
      continue;
    }
    for (auto [u, w] : g[v]) {
      int nc = c + w;
      if (nc < dis[u][0]) {
        if (dis[u][0] < dis[u][1]) {
          dis[u][1] = dis[u][0];
          pq.push(u, dis[u][1]); 
        }
        dis[u][0] = nc; 
      } else {
        dis[u][1] = nc; 
        pq.push(u, dis[u][1]);
      }
    }
  }
  return dis[0][1];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:30:31: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(std::tuple_element<0, std::pair<int, int> >::type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   30 |           pq.push(u, dis[u][1]);
      |                               ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   candidate expects 1 argument, 2 provided
crocodile.cpp:35:29: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(std::tuple_element<0, std::pair<int, int> >::type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   35 |         pq.push(u, dis[u][1]);
      |                             ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from crocodile.cpp:2:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<int, int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   candidate expects 1 argument, 2 provided