답안 #552613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552613 2022-04-23T12:27:09 Z QwertyPi Jakarta Skyscrapers (APIO15_skyscraper) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int dp[30001];
vector<int> G[30001];
int A[30001][2];
bool ok[30001][800][2];
int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < k; i++){
		cin >> A[i][0] >> A[i][1];
		G[A[i][0]].push_back(A[i][1]);
	}
	priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> q;
	q.push({0, A[0][0]});
	fill(dp, dp + n, (1 << 30));
	while(q.size()){
		tuple<int, int, int> qe = q.top(); q.pop();
		int v = get<0>(qe), w = get<1>(qe), ban = get<2>(qe);
		if(dp[v] != (1 << 30)) continue;
		dp[v] = w;
		// cout << v << ' ' << w << endl;
		for(auto i : G[v]){
			if(i % ban == 0) continue;
			for(int j = v % i; j < n; j += i){
				int d = abs(v - j) / i;
				if(dp[j] > w + d) q.push({w + d, j, i});
			}
		}
	}
	cout << (dp[A[1][0]] == (1 << 30) ? -1 : dp[A[1][0]]) << endl;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:18:21: error: no matching function for call to 'std::priority_queue<std::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::push(<brace-enclosed initializer list>)'
   18 |  q.push({0, A[0][0]});
      |                     ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from skyscraper.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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, 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::tuple<int, 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::tuple<int, int, int>; _Sequence = std::vector<std::tuple<int, int, int> >; _Compare = std::greater<std::tuple<int, int, int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::tuple<int, 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::tuple<int, int, int>, std::vector<std::tuple<int, int, int> >, std::greater<std::tuple<int, int, int> > >::value_type&&' {aka 'std::tuple<int, int, int>&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~