Submission #367264

# Submission time Handle Problem Language Result Execution time Memory
367264 2021-02-16T18:08:30 Z wind_reaper Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

const int INF = 1e9 + 1;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	vector<vector<pair<int, int>>> adj(N);
	for(int i = 0; i < M; i++){
		adj[R[i][0]].push_back({R[i][1], L[i]});
		adj[R[i][1]].push_back({R[i][0], L[i]});
	}

	priority_queue<pair<int, int>, vector<pair<int, int>, greater<pair<int, int>>> pq;
	vector<array<int, 2>> d(N, INF);
	for(int i = 0; i < K; i++){
		d[i] = {0, 0};
		pq.push({0, i});
	}

	while(!pq.empty()){
		auto[dv, node] = pq.top();
		pq.pop();

		if(dv > d[i][1]) continue;
		for(auto& [v, l] : adj[node]){
			int nx = dv + l;
			if(nx > d[v][1]) continue;
			d[v][1] = nx;
			if(d[v][1] < d[v][0]) swap(d[v][1], d[v][0]);
			q.push({nx, v});
		}
	}

	return (d[0][0] == INF ? -1 : d[0][0]);
}
/*int32_t main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	
	return 0; 
}*/
/*
implement something equivalent to a multi source dijkstra

Compilation message

crocodile.cpp:43:1: error: unterminated comment
   43 | /*
      | ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:14:81: error: template argument 2 is invalid
   14 |  priority_queue<pair<int, int>, vector<pair<int, int>, greater<pair<int, int>>> pq;
      |                                                                                 ^~
crocodile.cpp:14:81: error: template argument 3 is invalid
crocodile.cpp:15:32: error: no matching function for call to 'std::vector<std::array<int, 2> >::vector(int&, const int&)'
   15 |  vector<array<int, 2>> d(N, INF);
      |                                ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:650:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&)'
  650 |  vector(_InputIterator __first, _InputIterator __last,
      |  ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:650:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/9/bits/stl_algobase.h:65,
                 from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_types.h: In substitution of 'template<class _InIter> using _RequireInputIter = typename std::enable_if<std::is_convertible<typename std::iterator_traits<_Iterator>::iterator_category, std::input_iterator_tag>::value>::type [with _InIter = int]':
/usr/include/c++/9/bits/stl_vector.h:649:9:   required from here
/usr/include/c++/9/bits/stl_iterator_base_types.h:232:11: error: no type named 'iterator_category' in 'struct std::iterator_traits<int>'
  232 |     using _RequireInputIter = typename
      |           ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/functional:62,
                 from /usr/include/c++/9/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/9/algorithm:71,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:622:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  622 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:622:43: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<std::array<int, 2> >'
  622 |       vector(initializer_list<value_type> __l,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:604:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  604 |       vector(vector&& __rv, const allocator_type& __m)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:604:23: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::array<int, 2> >&&'
  604 |       vector(vector&& __rv, const allocator_type& __m)
      |              ~~~~~~~~~^~~~
/usr/include/c++/9/bits/stl_vector.h:586:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >; std::false_type = std::integral_constant<bool, false>]'
  586 |       vector(vector&& __rv, const allocator_type& __m, false_type)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:586:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/9/bits/stl_vector.h:582:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >; std::true_type = std::integral_constant<bool, true>]'
  582 |       vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:582:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/9/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  572 |       vector(const vector& __x, const allocator_type& __a)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:572:28: note:   no known conversion for argument 1 from 'int' to 'const std::vector<std::array<int, 2> >&'
  572 |       vector(const vector& __x, const allocator_type& __a)
      |              ~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >]'
  569 |       vector(vector&&) noexcept = default;
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:569:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:550:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >]'
  550 |       vector(const vector& __x)
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:550:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:519:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = std::array<int, 2>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  519 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:519:47: note:   no known conversion for argument 2 from 'const int' to 'const value_type&' {aka 'const std::array<int, 2>&'}
  519 |       vector(size_type __n, const value_type& __value,
      |                             ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/9/bits/stl_vector.h:507:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  507 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:507:51: note:   no known conversion for argument 2 from 'const int' to 'const allocator_type&' {aka 'const std::allocator<std::array<int, 2> >&'}
  507 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |                             ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:494:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::array<int, 2> >]'
  494 |       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:494:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:484:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >]'
  484 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/9/bits/stl_vector.h:484:7: note:   candidate expects 0 arguments, 2 provided
crocodile.cpp:18:3: error: 'pq' was not declared in this scope
   18 |   pq.push({0, i});
      |   ^~
crocodile.cpp:21:9: error: 'pq' was not declared in this scope
   21 |  while(!pq.empty()){
      |         ^~
crocodile.cpp:25:13: error: 'i' was not declared in this scope
   25 |   if(dv > d[i][1]) continue;
      |             ^
crocodile.cpp:31:4: error: 'q' was not declared in this scope
   31 |    q.push({nx, v});
      |    ^