Submission #501213

#TimeUsernameProblemLanguageResultExecution timeMemory
501213blueFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h"
#include <vector>
using namespace std;

// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[])
{
	vector<int> Yes(n, 0), No(n, 0); //dp if person i is chosen / not chosen
	for(int i = 0; i < n; i++) Yes[i] += confidence[i];

	for(int i = n-1; i >= 1; i--)
	{
		if(protocol[i] == 0) //I am your friend
		{
			//yes i, yes host[i]

			//no i, yes host[i]
			Yes[ host[i] ] += No[i];

			//yes i, no host[i]
			//no i, no host[i]
			No[ host[i] ] += max(Yes[i], No[i]);
		}
		else if(protocol[i] == 1) //My friends are your friends
		{
			//yes i, yes host[i]
			//no i, yes host[i]
			//yes i, no host[i]
			Yes[ host[i] ] = max(Yes[ host[i] ] + max(Yes[i], No[i]));//, No[ host[i] ] + Yes[i]);

			//no i, no host[i]
			No[ host[i] ] += No[i];
		}
		else //We are your friends
		{
			//yes i, yes host[i]

			//no i, yes host[i]
			//yes i, no host[i]
			Yes[ host[i] ] = max(Yes[ host[i] ] + No[i], No[ host[i] ] + Yes[i]);

			//no i, no host[i]
			No[ host[i] ] += No[i];
		}
	}

	return max(Yes[0], No[0]);
}

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:29:60: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   29 |    Yes[ host[i] ] = max(Yes[ host[i] ] + max(Yes[i], No[i]));//, No[ host[i] ] + Yes[i]);
      |                                                            ^
In file included from /usr/include/c++/10/vector:60,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
friend.cpp:29:60: note:   candidate expects 2 arguments, 1 provided
   29 |    Yes[ host[i] ] = max(Yes[ host[i] ] + max(Yes[i], No[i]));//, No[ host[i] ] + Yes[i]);
      |                                                            ^
In file included from /usr/include/c++/10/vector:60,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
friend.cpp:29:60: note:   candidate expects 3 arguments, 1 provided
   29 |    Yes[ host[i] ] = max(Yes[ host[i] ] + max(Yes[i], No[i]));//, No[ host[i] ] + Yes[i]);
      |                                                            ^