Submission #349617

# Submission time Handle Problem Language Result Execution time Memory
349617 2021-01-18T03:16:51 Z evn Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
typedef long long ll;
typedef pair<int, int> pii;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dist[1005];
vector<pii> adj[1005];
bool isExit[1005];
int ans = 1e9;
void dfs(int u, int p){
	for(pii e : adj[u]){
		int v=e.f;
		int w = e.s;
		if(v == p)continue;
		dist[v] = dist[u] + w;
		dfs(v, u);
	}
	vector<ll> children;
	for(pii e : adj[u]){
		if(e.f != p && isExit[e.f]){
			children.pb(dist[e.f]);
		}
	}
	sort(children.begin(), children.end());
	if(children.size() >= 2){
		ans = min(ans, children[1]);
	}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	for(int i =0; i < M; i++){
		adj[R[i][0]].pb({R[i][1], L[i]});
		adj[R[i][1]].pb({R[i][0], L[i]});
	}
	for(int i = 0; i < K; i++){
		isExit[P[i]] = true;
	}
	dfs(0, -1);
	return (int)ans;
}
/**
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N = 5;
	int M = 4;
	int R[N][2];
	int L[N];
	int K = 2;
	int P[K];
	cout << travel_plan(N, M);
}**/

Compilation message

crocodile.cpp: In function 'void dfs(int, int)':
crocodile.cpp:35:29: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   35 |   ans = min(ans, children[1]);
      |                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
crocodile.cpp:35:29: 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'})
   35 |   ans = min(ans, children[1]);
      |                             ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
crocodile.cpp:35:29: 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'})
   35 |   ans = min(ans, children[1]);
      |                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
crocodile.cpp:35:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   35 |   ans = min(ans, children[1]);
      |                             ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
crocodile.cpp:35:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   35 |   ans = min(ans, children[1]);
      |                             ^