답안 #954091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
954091 2024-03-27T09:13:55 Z 4QT0R 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>

struct edge{
	int to;
	int cost;
};

vector<edge> graph[100003];
pll odl[100003];
ll oo=1e18+1;

priority_queue<pll,vector<pll>,greater<pll>> pq;

void Dijkstra(){
	while(pq.size()){
		auto [d,v]=pq.top();
		pq.pop();
		if (odl[v].second<d)continue;
		for (auto u : graph[v]){
			if (d+u.cost<odl[u.to].first){
				odl[u.to].first=d+u.cost;
			}
			else if (d+u.cost<odl[u.to].second){
				odl[u.to].second=d+u.cost;
				pq.push(make_pair(odl[u.to].second,u.to));
			}
		}
	}
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	for (int i = 0; i<m; i++){
		graph[r[i][0]].push_back({r[i][1],l[i]});
		graph[r[i][1]].push_back({r[i][0],l[i]});
	}
	fill(odl,odl+n,make_pair(oo,oo));
	for (int i = 0; i<k; i++){
		pq.push({{0,0},p[i]});
		odl[p[i]]={0,0};
	}
	Dijkstra();
	return odl[0].second;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:41:23: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::push(<brace-enclosed initializer list>)'
   41 |   pq.push({{0,0},p[i]});
      |                       ^
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<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long 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<long long int, long long 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<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = std::greater<std::pair<long long int, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<long long int, long long 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<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, std::greater<std::pair<long long int, long long int> > >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~