Submission #570987

#TimeUsernameProblemLanguageResultExecution timeMemory
5709871neCommuter Pass (JOI18_commuter_pass)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
struct point{
	int64_t u,pp,bb;
};
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int64_t n,m;cin>>n>>m;
	int64_t S,T;cin>>S>>T;
	--S;--T;
	int64_t U,V;cin>>U>>V;
	--U;--V;
	vector<vector<pair<int64_t,int64_t>>>adj(n);
	for (int64_t i = 0;i<m;++i){
		int64_t x,y,z;cin>>x>>y>>z;
		--x;--y;
		adj[x].push_back({y,z});
		adj[y].push_back({x,z});
	}
	const int64_t mxn = 1e18;
	priority_queue<pair<int64_t,pair<int64_t,int64_t>>>q;
	vector<vector<int64_t>>dist(n,vector<int64_t>(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}});
			}
		}
	}
	int64_t ans = dist[U][1];
	vector<int64_t>dis(n,mxn);
	priority_queue<pair<long long,long long>>qs;
	qs.push({0,S});
	dis[S] = 0;
	vector<vector<int64_t>>dp(n,vector<int64_t>(4,mxn));
	while(!qs.empty()){
		auto u = qs.top();
		qs.pop();
		if (-u.first > dis[u.second])continue;
		for (auto x:adj[u.second]){
			if (dis[x.first] > dis[u.second] + x.second){
				dis[x.first] = dis[u.second] + x.second;
				qs.push({-dis[x.first],x.first});
			}
		}
	}
	dp[S][1] = dist[S][0];
	dp[S][2] = dist[S][1];
	vector<bool>visited(n,false);
	dp[S][3] = dist[S][0] + dist[S][1];
  	dp[S][0] = 0;
	auto bfs = [&](){
		set<int>qq;
		qq.insert({0,S});
		while(!qq.empty()){
			auto u = *qq.begin().second;
			qq.erase(qq.begin());
			visited[u] = true;
			for (auto x:adj[u]){
				if (dis[x.first] == dis[u] + x.second && !visited[x.first]){
					qq.insert({dis[x.first],x.first});
					auto get = [&](int64_t v,int64_t j){
						int64_t res = 0;
						if (j & 1)res+=dist[v][0];
						if (j & 2)res+=dist[v][1];
						return res;
					};
					for (int i = 0;i < 4;++i){
						for (int j = 0;j<4;++j){
							dp[x.first][i | j] = min(dp[x.first][i | j],dp[u][i] + get(x.first,j));
						}
					}
				}
			}
		}
		ans = min(ans,dp[T][3]);
	};
	bfs();
	cout<<ans<<'\n';
	return 0;
}

Compilation message (stderr)

commuter_pass.cpp: In lambda function:
commuter_pass.cpp:62:16: warning: narrowing conversion of 'S' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
   62 |   qq.insert({0,S});
      |                ^
commuter_pass.cpp:62:16: warning: narrowing conversion of 'S' from 'int64_t' {aka 'long int'} to 'int' [-Wnarrowing]
commuter_pass.cpp:64:25: error: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} has no member named 'second'
   64 |    auto u = *qq.begin().second;
      |                         ^~~~~~
commuter_pass.cpp:69:38: error: no matching function for call to 'std::set<int>::insert(<brace-enclosed initializer list>)'
   69 |      qq.insert({dis[x.first],x.first});
      |                                      ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from commuter_pass.cpp:1:
/usr/include/c++/10/bits/stl_set.h:509:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = int]'
  509 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:509:32: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
  509 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:518:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = int]'
  518 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:518:27: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<int>::value_type&&' {aka 'int&&'}
  518 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:546:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, const value_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = int]'
  546 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:546:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_set.h:551:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(std::set<_Key, _Compare, _Alloc>::const_iterator, std::set<_Key, _Compare, _Alloc>::value_type&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; std::set<_Key, _Compare, _Alloc>::value_type = int]'
  551 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:551:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/10/bits/stl_set.h:566:2: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  566 |  insert(_InputIterator __first, _InputIterator __last)
      |  ^~~~~~
/usr/include/c++/10/bits/stl_set.h:566:2: note:   template argument deduction/substitution failed:
commuter_pass.cpp:69:38: note:   candidate expects 2 arguments, 1 provided
   69 |      qq.insert({dis[x.first],x.first});
      |                                      ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from commuter_pass.cpp:1:
/usr/include/c++/10/bits/stl_set.h:578:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  578 |       insert(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_set.h:578:43: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<int>'
  578 |       insert(initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~