Submission #933468

#TimeUsernameProblemLanguageResultExecution timeMemory
933468JuanJLCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

#define fst first 
#define snd second
#define pb push_back
#define forn(i,a,b) for(int i = a; i < b; i++)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n';
#define pi pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset;

ll n,m,k,h;
vector<vector<pll>> adj;
vector<ll> type;
vector<bool> disp;

void dfs(ll nd){
	if(disp[nd]) return;
	disp[nd]=1;
	if(nd==h) return;
	for(auto i:adj[nd]) dfs(i.fst);
}

double Dijkstra(){
	double dist[n+5][30+5];
	forn(i,0,n+5) forn(j,0,30+5) dist[i][j]=-1;
	priority_queue<pair<double,pair<ll,ll>>> pq;
	pq.push({0,{0,0}});
	forn(i,0,30+5) dist[0][i]=0;
	forn(i,0,n){
		if(type[i]==0&&disp[i]){
			pq.push({0,{0,i}});
			forn(j,0,30+5) dist[i][j]=0;
		}
	}
	
	while(!pq.empty()){
		double cost = pq.top().fst*-1;
		ll nd = pq.top().snd.snd;
		ll p2 = pq.top().snd.fst;
		pq.pop();
		if(cost>dist[nd][p2]) continue;
		
		if(nd==h) continue;
		
		for(auto i:adj[nd]){
			ll ndV = i.fst;
			double nCost = i.snd+cost;
			if(type[ndV]==0) continue;
			if(nCost<dist[ndV][p2]||dist[ndV][p2]==-1){
				dist[ndV][p2]=nCost;
				pq.push({dist[ndV][p2]*-1,{p2,ndV}});
			}
			if(type[ndV]==2&&p2+1<min(35,k)){
				nCost/=2;
				if(nCost<dist[ndV][p2+1]||dist[ndV][p2+1]==-1){
					dist[ndV][p2+1]=nCost;
					pq.push({dist[ndV][p2+1]*-1,{p2+1,ndV}});					
				}
			}
		}
	}
	double res = -1;
	forn(i,0,30+5) if(dist[h][i]!=-1&&(res>dist[h][i]||res==-1))  res = dist[h][i];
	return (double)res;
}	


double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr){
	n=N;m=M;k=K;h=H;
	adj.clear();
	adj.resize(n);
	type.clear();
	type.resize(n);
	disp.clear();
	disp.resize(n,0);
	forn(i,0,SZ(x))	adj[x[i]].pb({y[i],c[i]}),adj[y[i]].pb({x[i],c[i]});
	forn(i,0,n) type[i]=arr[i];
	dfs(0);
	return Dijkstra();
}

Compilation message (stderr)

cyberland.cpp: In function 'double Dijkstra()':
cyberland.cpp:64:34: error: no matching function for call to 'min(int, ll&)'
   64 |    if(type[ndV]==2&&p2+1<min(35,k)){
      |                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
cyberland.cpp:64:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   64 |    if(type[ndV]==2&&p2+1<min(35,k)){
      |                                  ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
cyberland.cpp:64:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   64 |    if(type[ndV]==2&&p2+1<min(35,k)){
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
cyberland.cpp:64:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   64 |    if(type[ndV]==2&&p2+1<min(35,k)){
      |                                  ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
cyberland.cpp:64:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   64 |    if(type[ndV]==2&&p2+1<min(35,k)){
      |                                  ^