Submission #903157

# Submission time Handle Problem Language Result Execution time Memory
903157 2024-01-11T05:58:57 Z Muhammad_Aneeq Friend (IOI14_friend) C++17
19 / 100
1000 ms 42284 KB
#include <vector>
#include <iostream>
#include <set>
using namespace std;
int const N=1000;
set<int>nei[N]={};
int vis[N]={};
int ans=0;
int nn;
int val[N]={};
bool w=0;
void dfs(int i,int val1)
{
	for (int j=0;j<nn;j++)
	{
		if (i==j)
			continue;
		if (vis[j]&&nei[i].find(j)!=nei[i].end())
			return;
	}
	for (int j=0;j<nn;j++)
	{
		if (i==j)
			continue;
		if (nei[i].find(j)==nei[i].end()&&!vis[j])
		{
			vis[j]=1;
			dfs(j,val1+val[j]);
			if (w==0)
				vis[j]=0;
		}
	}
	ans=max(ans,val1);
}
int findSample(int n,int confidence[],int host[],int protocol[])
{
	nn=n;
	for (int i=0;i<n;i++)
		val[i]=confidence[i];
	set<int>s;
	for (int i=1;i<n;i++)
	{
		s.insert(protocol[i]);
		if (protocol[i]==0)
		{
			nei[i].insert(host[i]);
			nei[host[i]].insert(i);
		}
		else if (protocol[i]==1)
		{
			for (int j=0;j<n;j++)
			{
				if (i==j)
					continue;
				if (nei[host[i]].find(j)!=nei[host[i]].end())
				{
					nei[i].insert(j);
					nei[j].insert(i);
				}
			}
		}
		else
		{
			nei[i].insert(host[i]);
			nei[host[i]].insert(i);
			for (int j=0;j<n;j++)
			{
				if (i==j)
					continue;
				if (nei[host[i]].find(j)!=nei[host[i]].end())
				{
					nei[i].insert(j);
					nei[j].insert(i);
				}
			}
		}
	}
	if (s.size()==1&&*begin(s)==1)
	{
		int ans=0;
		for (int i=0;i<n;i++)
			ans+=val[i];
		return ans;
	}
		vis[0]=1;
		dfs(0,val[0]);
		vis[0]=0;
		for (auto j:nei[0])
		{
			vis[j]=1;
			dfs(j,val[j]);
			vis[j]=0;
		}
		return ans;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Correct 1 ms 360 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 8944 KB Output is correct
2 Runtime error 311 ms 42284 KB Memory limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Execution timed out 1063 ms 628 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 600 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Execution timed out 1087 ms 620 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Runtime error 28 ms 2896 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -