제출 #967062

#제출 시각아이디문제언어결과실행 시간메모리
967062akacool445k사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
// #define int long long
#define ff first
#define ss second
const int shrek = 1e5;
vector< vector<pair<int, int>>> adj(shrek);

double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    vector<int> dist (n);
    for(int i = 0; i < n; i++) dist[i] = -1;
    for(int i = 0; i < m; i++) {
        adj[x[i]].push_back({y[i], c[i]});
        adj[y[i]].push_back({x[i], c[i]});
    }
    priority_queue <pair<int, int>> q;
    q.push({0, 0});
    while(!q.empty()) {
        double d = -q.top().ff;
        int u = q.top().ss;
        q.pop();
        if(dist[p.ss] != -1) continue;
        dist[u] = d;
        for(auto x : adj[p.ss]) {
            q.push({-(d + x.ss), x.ff});
        }
    }
    double ans = dist[h];
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:23:17: error: 'p' was not declared in this scope
   23 |         if(dist[p.ss] != -1) continue;
      |                 ^
cyberland.cpp:25:26: error: 'p' was not declared in this scope
   25 |         for(auto x : adj[p.ss]) {
      |                          ^
cyberland.cpp:26:39: error: no matching function for call to 'std::priority_queue<std::pair<int, int> >::push(<brace-enclosed initializer list>)'
   26 |             q.push({-(d + x.ss), x.ff});
      |                                       ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from cyberland.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::less<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::less<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> >::value_type&&' {aka 'std::pair<int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~