Submission #131246

# Submission time Handle Problem Language Result Execution time Memory
131246 2019-07-16T21:17:28 Z arthurconmy Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
/* Arthur Conmy / arthurconmy */
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>

#ifndef ARTHUR_LOCAL
	#include "crocodile.h"
#endif

using namespace std;

const int MAXN=1001;
pair<int,int> adj[MAXN];
bool vis[MAXN];
bool leaf[MAXN];

void update(int NEW, int &FIR, int &SEC)
{
	if(NEW>=FIR)
	{
		SEC=FIR;
		FIR=NEW;
	}

	else
	{
		SEC=max(SEC,NEW);
	}
}

int dfs(int v)
{
	vis[v]=1;

	int best=int(1e9);
	int second_best=int(1e9);

	for(auto u:adj[v])
	{
		if(vis[u.ff]) continue;

		if(leaf[u.ff])
		{
			update(u.ss, best, second_best);
		}

		else
		{
			update(u.ss+dfs(v), best, second_best);
		}
	}

	return second_best;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i=0; i<N-1; i++)
	{
		adj[R[i][0]].push_back(make_pair(R[i][1],L[i]));
		adj[R[i][1]].push_back(make_pair(R[i][0],L[i]));
	}

	for(int i=0; i<K; i++)
	{
		leaf[P[i]]=1;
	}

	int ans=0;

	for(int i=0; i<N; i++)
	{
		if(!leaf[i])
		{
			ans=max(ans,dfs(i));

			for(int j=0; j<N; j++)
			{
				vis[j]=0;
			}
		}
	}

	return ans;
}

// int R[9][2];
// int L[9];
// int P[6];

// int main()
// {
// 	#ifdef ARTHUR_LOCAL
// 		ifstream cin("input.txt");
// 	#endif

// 	cout << travel_plan(10,9,R,L,6,P);

// 	R[0][0]=0;
// 	R[0][1]=1;
// 	R[1][0]=0;
// 	R[1][1]=2;
// 	R[2][0]=0;
// 	R[2][1]=3;
// 	R[3][0]=1;
// 	R[3][1]=4;
// 	R[4][0]=1;
// 	R[4][1]=5;
// 	R[5][0]=2;
// 	R[5][1]=6;
// 	R[6][0]=2;
// 	R[6][1]=7;
// 	R[7][0]=3;
// 	R[7][1]=8;
// 	R[8][0]=3;
// 	R[8][1]=9;

// 	L[0]=4;
// 	L[1]=6;
// 	L[2]=
// }

Compilation message

crocodile.cpp: In function 'int dfs(int)':
crocodile.cpp:48:18: error: no matching function for call to 'begin(std::pair<int, int>&)'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:105:37: note: candidate: template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)
   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
                                     ^~~~~
/usr/include/c++/7/bits/range_access.h:105:37: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:104:31: note: candidate: template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)
   template<typename _Tp> _Tp* begin(valarray<_Tp>&);
                               ^~~~~
/usr/include/c++/7/bits/range_access.h:104:31: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:87:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])
     begin(_Tp (&__arr)[_Nm])
     ^~~~~
/usr/include/c++/7/bits/range_access.h:87:5: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:58:5: note: candidate: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&)
     begin(const _Container& __cont) -> decltype(__cont.begin())
     ^~~~~
/usr/include/c++/7/bits/range_access.h:58:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
crocodile.cpp:48:18:   required from here
/usr/include/c++/7/bits/range_access.h:58:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
     begin(const _Container& __cont) -> decltype(__cont.begin())
                                                 ~~~~~~~^~~~~
/usr/include/c++/7/bits/range_access.h:48:5: note: candidate: template<class _Container> decltype (__cont.begin()) std::begin(_Container&)
     begin(_Container& __cont) -> decltype(__cont.begin())
     ^~~~~
/usr/include/c++/7/bits/range_access.h:48:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
crocodile.cpp:48:18:   required from here
/usr/include/c++/7/bits/range_access.h:48:50: error: 'struct std::pair<int, int>' has no member named 'begin'
     begin(_Container& __cont) -> decltype(__cont.begin())
                                           ~~~~~~~^~~~~
In file included from /usr/include/c++/7/bits/range_access.h:36:0,
                 from /usr/include/c++/7/string:51,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/initializer_list:89:5: note: candidate: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)
     begin(initializer_list<_Tp> __ils) noexcept
     ^~~~~
/usr/include/c++/7/initializer_list:89:5: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
  for(auto u:adj[v])
                  ^
crocodile.cpp:48:18: error: no matching function for call to 'end(std::pair<int, int>&)'
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:107:37: note: candidate: template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
   template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
                                     ^~~
/usr/include/c++/7/bits/range_access.h:107:37: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:106:31: note: candidate: template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
   template<typename _Tp> _Tp* end(valarray<_Tp>&);
                               ^~~
/usr/include/c++/7/bits/range_access.h:106:31: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:97:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^~~
/usr/include/c++/7/bits/range_access.h:97:5: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
  for(auto u:adj[v])
                  ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/bits/range_access.h:78:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^~~
/usr/include/c++/7/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
crocodile.cpp:48:18:   required from here
/usr/include/c++/7/bits/range_access.h:78:54: error: 'const struct std::pair<int, int>' has no member named 'end'; did you mean 'second'?
     end(const _Container& __cont) -> decltype(__cont.end())
                                               ~~~~~~~^~~
                                               second
/usr/include/c++/7/bits/range_access.h:68:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^~~
/usr/include/c++/7/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
/usr/include/c++/7/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
crocodile.cpp:48:18:   required from here
/usr/include/c++/7/bits/range_access.h:68:48: error: 'struct std::pair<int, int>' has no member named 'end'; did you mean 'second'?
     end(_Container& __cont) -> decltype(__cont.end())
                                         ~~~~~~~^~~
                                         second
In file included from /usr/include/c++/7/bits/range_access.h:36:0,
                 from /usr/include/c++/7/string:51,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from crocodile.cpp:2:
/usr/include/c++/7/initializer_list:99:5: note: candidate: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
/usr/include/c++/7/initializer_list:99:5: note:   template argument deduction/substitution failed:
crocodile.cpp:48:18: note:   'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
  for(auto u:adj[v])
                  ^
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:70:16: error: 'struct std::pair<int, int>' has no member named 'push_back'
   adj[R[i][0]].push_back(make_pair(R[i][1],L[i]));
                ^~~~~~~~~
crocodile.cpp:71:16: error: 'struct std::pair<int, int>' has no member named 'push_back'
   adj[R[i][1]].push_back(make_pair(R[i][0],L[i]));
                ^~~~~~~~~