Submission #1000967

# Submission time Handle Problem Language Result Execution time Memory
1000967 2024-06-18T12:01:48 Z 0npata Cyberland (APIO23_cyberland) C++17
Compilation error
0 ms 0 KB
#include "cyberland.h"
#include<bits/stdc++.h>

using namespace std;

#define vec vector
#define int long long
#define float long double

const float INF = 1e18;

double solve(int32_t N, int32_t M, int32_t K, int32_t H, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> c, std::vector<int32_t> t) {
	float ans = INF;


	int n = N;
	int m = M;
	int k = K;

	priority_queue<pair<pair<int, float>, int>, vector<pair<pair<int, float>, int>>, greater<pair<pair<int, float>, int>>> pq;
	vec<vec<bool>> vis(k+2, vec<bool>(n, false));

	vec<vec<pair<int, int>>> g(n);

	for(int i = 0; i<m; i++) {
		g[x[i]].push_back({y[i], c[i]});
		g[y[i]].push_back({x[i], c[i]});
	}

	pq.push({{0, 0}, 0});

	vec<bool> dfs_vis(n, false);
	vec<int> stk{0};
	dfs_vis[0] = true;
	while(stk.size() > 0) {
		int u = stk.back();
		stk.pop_back();

		if(u==H) continue;

		if(t[u] == 0) {
			pq.push({{0, 0}, u});
		}

		for(auto e : g[u]) {
			if(dfs_vis[e.first]) continue;
			stk.push_back(e.first);
			dfs_vis[e.first] = true;
		}
	}

	while(pq.size() > 0) {
		pair<pair<int, float>, int> cur = pq.top();
		pq.pop();

		int ck = cur.first.first;
		float d = cur.first.second;
		int u = cur.second;


		if(ck > k) break;

		if(u == H) {
			ans = min(ans, d);
			continue;
		}
		if(vis[ck][u]) {
			continue;
		}
		vis[ck][u] = true;

		for(auto e : g[u]) {
			int v = e.first;
			float w = e.second;

			if(vis[ck][v]) continue;
			pq.push({{ck, d+w}, v});
			if(t[v] == 2) {
				pq.push({ck+1, (d+w)/2}, v);
			}
		}
	}

	if(abs(ans - INF) < 1000) return -1;

	return ans;
}

Compilation message

cyberland.cpp: In function 'double solve(int32_t, int32_t, int32_t, int32_t, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:79:31: error: no matching function for call to 'std::priority_queue<std::pair<std::pair<long long int, long double>, long long int>, std::vector<std::pair<std::pair<long long int, long double>, long long int> >, std::greater<std::pair<std::pair<long long int, long double>, long long int> > >::push(<brace-enclosed initializer list>, long long int&)'
   79 |     pq.push({ck+1, (d+w)/2}, v);
      |                               ^
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: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<std::pair<long long int, long double>, long long int>; _Sequence = std::vector<std::pair<std::pair<long long int, long double>, long long int> >; _Compare = std::greater<std::pair<std::pair<long long int, long double>, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<std::pair<long long int, long double>, long long 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<std::pair<long long int, long double>, long long int>; _Sequence = std::vector<std::pair<std::pair<long long int, long double>, long long int> >; _Compare = std::greater<std::pair<std::pair<long long int, long double>, long long int> >; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = std::pair<std::pair<long long int, long double>, long long int>]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note:   candidate expects 1 argument, 2 provided