Submission #349613

# Submission time Handle Problem Language Result Execution time Memory
349613 2021-01-18T03:07:11 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>;
ll dist[1005];
vector<pii> adj[1005];
bool isExit[1005];
ll ans = 1e18;
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] + 1LL * w;
		dfs(v, u);
	}
	vector<ll> children;
	for(pii e : adj[u]){
		if(e.f != p){
			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, vector<vector<int>> R, vector<int> L, int K, vector<int> P){
	for(int i =0; i < R.size(); i++){
		adj[R[i][0]].pb({adj[R[i][1]], L[i]});
		adj[R[i][1]].pb({adj[R[i][0]], L[i]});
	}
	for(int i = 0; i < K; i++){
		isExit[P[i]] = true;
	}
	dfs(0, -1);
	cout << ans << '\n';
}
/**
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}**/

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, std::vector<std::vector<int> >, std::vector<int>, int, std::vector<int>)':
crocodile.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i =0; i < R.size(); i++){
      |                ~~^~~~~~~~~~
crocodile.cpp:40:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   40 |   adj[R[i][0]].pb({adj[R[i][1]], L[i]});
      |                                       ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
crocodile.cpp:41:39: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   41 |   adj[R[i][1]].pb({adj[R[i][0]], L[i]});
      |                                       ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
crocodile.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^