답안 #1104290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104290 2024-10-23T12:01:47 Z KasymK 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
vector<pii> adj[N];
short int vis[N];
int dis[N];
 
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    for(int i = 0; i < m; ++i)
        adj[R[i][0]].pb({R[i][1], L[i]}), adj[R[i][1]].pb({R[i][0], L[i]});
    for(int i = 0; i < k; ++i)
        q.push({0, P[i]}), val[P[i]] = 1;
    while(!pq.empty()){
        int val = pq.top().ff, x = pq.top().ss;
        pq.pop();
        if(vis[x]==2)
            continue;
        vis[x]++;
        if(vis[x]==1)
            continue;
        dis[x] = val;
        tr(it, adj[x])
            if(vis[it->ff] != 2)
                pq.push({val+it->ss, a});
    }
    return dis[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:25:9: error: 'q' was not declared in this scope
   25 |         q.push({0, P[i]}), val[P[i]] = 1;
      |         ^
crocodile.cpp:25:28: error: 'val' was not declared in this scope
   25 |         q.push({0, P[i]}), val[P[i]] = 1;
      |                            ^~~
crocodile.cpp:37:38: error: 'a' was not declared in this scope
   37 |                 pq.push({val+it->ss, a});
      |                                      ^
crocodile.cpp:37:40: 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(<brace-enclosed initializer list>)'
   37 |                 pq.push({val+it->ss, a});
      |                                        ^
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:1:
/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:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/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:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~