제출 #926653

#제출 시각아이디문제언어결과실행 시간메모리
926653Wansur사이버랜드 (APIO23_cyberland)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
 
using namespace std;
typedef long long ll;
const int mx=1e5+12;
 
vector<pair<int,int>> g[mx];
long double d[mx][101];
bool was[mx][101];
bool used[mx];
 
void dfs(int v){
	used[v]=1;
	for(auto to:g[v]){
		if(!used[to.f]){
			dfs(to.f);
		}
	}
}
 
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr){
	k=min(k,70);
	for(int i=0;i<n;i++){
		g[i].clear();
		used[i]=0;
	}
	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]});
	}
	dfs(0);
	if(!used[h]){
		return -1;
	}
	for(int i=0;i<n;i++){
		for(int x=0;x<=k;x++){
			d[i][x]=2e14;
			was[i][x]=0;
		}
		used[i]=0;
	}
	used[h]=1;
	dfs(0);
	priority_queue<pair<long double,pair<int,int>>> s;
	d[0][0]=0;
	s.push({0,{0,0}});
	for(int i=0;i<n;i++){
		if(used[i] && arr[i]==0){
			d[i][0]=0;
			s.push({0,{i,0}});
		}
	}
	while(s.size()){
		int v=s.top().s.f,x=s.top().s.s;
		s.pop();
		if(v==h)continue;
		if(was[v][x])continue;
		was[v][x]=1;
		for(auto To:g[v]){
			int to=To.f;
			long long w=To.s;
			if(d[to][x]>d[v][x]+w){
				d[to][x]=d[v][x]+w;
				s.push({-d[to][x],{to,x}});
			}
			if(x<k && d[to][x+1]>d[v][x]/2.0+w && arr[v]==2){
				d[to][x+1]=d[v][x]/2.0+w;
				s.push({-d[to][x+1],{to,x+1}});
			}
		}
	}
	double ans=2e14;
	for(int x=k;x>=0;x--){
		if(d[h][x]>=2e14)continue;
		ans=min(ans,d[h][x]);
		if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
	}
	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:78:22: error: no matching function for call to 'min(double&, long double&)'
   78 |   ans=min(ans,d[h][x]);
      |                      ^
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:78:22: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   78 |   ans=min(ans,d[h][x]);
      |                      ^
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:78:22: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   78 |   ans=min(ans,d[h][x]);
      |                      ^
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:78:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   78 |   ans=min(ans,d[h][x]);
      |                      ^
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:78:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   78 |   ans=min(ans,d[h][x]);
      |                      ^
cyberland.cpp:79:66: error: no matching function for call to 'min(double&, long double)'
   79 |   if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
      |                                                                  ^
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:79:66: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   79 |   if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
      |                                                                  ^
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:79:66: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'long double')
   79 |   if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
      |                                                                  ^
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:79:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   79 |   if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
      |                                                                  ^
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:79:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   79 |   if(arr[h]==2 && x>0 && d[h][x-1]<2e14)ans=min(ans,d[h][x-1]/2.0);
      |                                                                  ^