Submission #570690

#TimeUsernameProblemLanguageResultExecution timeMemory
5706901neCommuter Pass (JOI18_commuter_pass)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,m;cin>>n>>m;
	int S,T;cin>>S>>T;
	--S;--T;
	int U,V;cin>>U>>V;
	--U;--V;
	vector<vector<pair<int,long long>>>adj(n);
	for (int i = 0;i<m;++i){
		int x,y,z;cin>>x>>y>>z;
		--x;--y;
		adj[x].push_back({y,z});
		adj[y].push_back({x,z});
	}
	const long long mxn = 1e15;
	priority_queue<pair<long long,pair<int,int>>>q;
	vector<vector<long long>>dist(n,vector<long long>(2,mxn));
	q.push({0,{U,0}});
	q.push({0,{V,1}});
	dist[U][0] = 0;
	dist[V][1] = 0;
	while(!q.empty()){
		auto u = q.top().second;
		q.pop();
		for (auto x:adj[u.first]){
			if (dist[x.first][u.second] > dist[u.first][u.second] + x.second){
				dist[x.first][u.second] = dist[u.first][u.second] + x.second;
				q.push({-dist[x.first][u.second],{x.first,u.second}});
			}
		}
	}
	vector<int>parent(n,-1);
	long long ans = dist[U][1];
	vector<long long>dis(n,mxn);
	auto bfs = [&](){
		priority_queue<pair<long long,int>>qq;
		qq.push({0,S});
		dis[S] = 0;
		while(!qq.empty()){
			auto u = qq.top().second;
			qq.pop();
			for (auto x:adj[u]){
				if (dis[x.first] > dis[u] + x.second){
					dis[x.first] = dis[u] + x.second;
					qq.push({-dis[x.first],x.first});
				}
			}
		}
		return dis[T];
	};
	long long minny = bfs();
	function<void(int,long long)>dfs = [&](int u,long long dd,int pp,int bb){
		if (u == T){
			if (dd > minny)return;
			ans = min(ans,pp + bb);
			return;
		}
		for (auto x:adj[u]){
			if (parent[x.first]==-1 && dd + x.second <=dis[x.first]){
				visited[x.first] = true;
				dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
				visited[x.first] = false;
			}
		}
	};
	dfs(S,0);
	cout<<ans<<'\n';
	return 0;
}

Compilation message (stderr)

commuter_pass.cpp: In lambda function:
commuter_pass.cpp:59:25: error: no matching function for call to 'min(long long int&, int)'
   59 |    ans = min(ans,pp + bb);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:59:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   59 |    ans = min(ans,pp + bb);
      |                         ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:59:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   59 |    ans = min(ans,pp + bb);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:59:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   59 |    ans = min(ans,pp + bb);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:59:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   59 |    ans = min(ans,pp + bb);
      |                         ^
commuter_pass.cpp:64:5: error: 'visited' was not declared in this scope
   64 |     visited[x.first] = true;
      |     ^~~~~~~
commuter_pass.cpp:65:54: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                      ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:65:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                      ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:65:54: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:65:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:65:54: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                      ^
commuter_pass.cpp:65:79: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int&)'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:65:79: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                                               ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from commuter_pass.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:
commuter_pass.cpp:65:79: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:65:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from commuter_pass.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:
commuter_pass.cpp:65:79: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   65 |     dfs(x.first,dd + x.second,min(pp,dist[x.first][0]),min(dist[x.first][1],bb));
      |                                                                               ^
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:69:2: error: conversion from 'main()::<lambda(int, long long int, int, int)>' to non-scalar type 'std::function<void(int, long long int)>' requested
   69 |  };
      |  ^