Submission #404203

#TimeUsernameProblemLanguageResultExecution timeMemory
404203wmrmrFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;

bool adj[10][10];
int n;
int confidence[MAX], host[MAX], protocol[MAX], dp[MAX][2];
vector<int> g[MAX];

void pt4_DFS(int v, int pai)
{
	dp[v][1] += confidence[v];
	for( int=0;i<g[v].size();i++ )
	{
		int prox = g[v][i];
		if(prox == pai) continue;
		pt4_DFS(prox,v);
		dp[v][0] += max( dp[prox][0] , dp[prox][1]);
		dp[v][1] += dp[prox][0];	
	}
}

// Find out best sample
int findSample(int tn,int tconfidence[],int thost[],int tprotocol[]){
	int ans = 0;
	n = tn;
	for(int i=0;i<n;i++) confidence[i] = tconfidence[i], host[i] = thost[i], protocol[i] = tprotocol[i];

	bool pt2 = 1, pt3 = 1, pt4 = 1;
	for(int i=1;i<n;i++)
	{
		if(protocol[i] != 0) pt4 = 0;
		if(protocol[i] != 1) pt2 = 0;
		if(protocol[i] != 2) pt3 = 0;
	}
	if(n <= 10)
	{
		ans = 0;
		for(int i=1;i<n;i++)
		{
			int p = host[i];
			if(protocol[i] != 1) adj[i][p] = adj[p][i] = 1;
			if(protocol[i] != 0)
				for(int j=0;j<i;j++)
					adj[i][j] = adj[j][i] = adj[j][i] || adj[p][j];
		}
		int dbg = 0;
		for(int cur = 0 ; cur < (1<<n) ; cur++)
		{
			bool valid = 1;
			for(int i=0;i<n;i++) for(int j=i+1;j<n;j++)
			{
				if( (cur&(1<<i)) && (cur&(1<<j)) )
					if(adj[i][j]) valid = 0;
			}
			int temp = 0;
			for(int i=0;i<n;i++)
				if(cur&(1<<i)) temp += confidence[i];
			if(valid) ans = max(ans,temp), dbg = cur;
		}
		return ans;
	}
	if(pt2)
	{
		for(int i=0;i<n;i++) ans += confidence[i];
		return ans;
	}
	if(pt3)
	{
		for(int i=0;i<n;i++) ans = max(ans,confidence[i]);
		return ans;
	}
	if(n <= 1e3)
	{
		for(int i=1;i<n;i++)
		{
			int p = host[i];
			if(protocol[i] != 1) g[i].push_back(p), g[p].push_back(i);
			if(protocol[i] != 0)
			{
				for(int j=0;j<v[p].size();j++)
				{
					int prox = v[p][j];
					g[prox].push_back(i); g[i].push_back(prox);
				}
			}
		}
	}
	if(pt4)
	{
		pt4_DFS(0,0);
		return max( dp[0][0] , dp[0][1] );
	}
	return 0;
}

Compilation message (stderr)

friend.cpp: In function 'void pt4_DFS(int, int)':
friend.cpp:14:10: error: expected unqualified-id before '=' token
   14 |  for( int=0;i<g[v].size();i++ )
      |          ^
friend.cpp:14:10: error: expected ';' before '=' token
   14 |  for( int=0;i<g[v].size();i++ )
      |          ^
      |          ;
friend.cpp:14:10: error: expected primary-expression before '=' token
friend.cpp:14:13: error: 'i' was not declared in this scope
   14 |  for( int=0;i<g[v].size();i++ )
      |             ^
friend.cpp:14:26: error: expected ')' before ';' token
   14 |  for( int=0;i<g[v].size();i++ )
      |     ~                    ^
      |                          )
friend.cpp:14:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |  for( int=0;i<g[v].size();i++ )
      |  ^~~
friend.cpp:14:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   14 |  for( int=0;i<g[v].size();i++ )
      |                           ^
friend.cpp:14:27: error: 'i' was not declared in this scope
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:82:19: error: 'v' was not declared in this scope
   82 |     for(int j=0;j<v[p].size();j++)
      |                   ^