Submission #501218

#TimeUsernameProblemLanguageResultExecution timeMemory
501218blueFriend (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] ], No[ host[i] ]) + max(Yes[i], No[i]));
			// Yes[ host[i] ] = Yes[ host[i] ] + max(Yes[i], No[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:76: error: expected ';' before ')' token
   29 |    Yes[ host[i] ] = max(Yes[ host[i] ], No[ host[i] ]) + max(Yes[i], No[i]));
      |                                                                            ^
      |                                                                            ;