Submission #903103

# Submission time Handle Problem Language Result Execution time Memory
903103 2024-01-11T05:40:26 Z Muhammad_Aneeq Friend (IOI14_friend) C++17
27 / 100
1000 ms 35432 KB
#include <vector>
#include <iostream>
#include <set>
#include "friend.h"
using namespace std;
int const N=2000;
int ed[N][N]={};
int vis[N]={};
int ans=0;
int nn;
int val[N]={};
set<int>s;
void dfs(int i,int val1)
{
	for (int j=0;j<nn;j++)
	{
		if (i==j)
			continue;
		if (vis[j]&&ed[i][j]==0)
			return;
	}
	for (int j=0;j<nn;j++)
	{
		if (i==j)
			continue;
		if (ed[i][j]&&!vis[j])
		{
			vis[j]=1;
			dfs(j,val1+val[j]);
			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];
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			ed[i][j]=1;
		set<int>s;
	for (int i=1;i<n;i++)
	{
		s.insert(protocol[i]);
		if (protocol[i]==0)
			ed[i][host[i]]=ed[host[i]][i]=0;
		else if (protocol[i]==1)
		{
			for (int j=0;j<n;j++)
			{
				if (ed[host[i]][j]==0)
					ed[i][j]=ed[j][i]=0;
			}
		}
		else
		{
			ed[i][host[i]]=ed[host[i]][i]=0;
			for (int j=0;j<n;j++)
			{
				if (ed[host[i]][j]==0)
					ed[i][j]=ed[j][i]=0;
			}
		}
	}
	if (s.size()==1&&*begin(s)==1)
	{
		int ans=0;
		for (int i=0;i<n;i++)
			ans+=val[i];
		return ans;
	}
	for (int i=0;i<n;i++)
	{
		vis[i]=1;
		dfs(i,val[i]);
		vis[i]=0;
	}
	return ans;
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:40:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |  for (int i=0;i<n;i++)
      |  ^~~
friend.cpp:43:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |   set<int>s;
      |   ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2488 KB Output is correct
4 Correct 1 ms 2492 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2400 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2488 KB Output is correct
13 Correct 1 ms 2492 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2488 KB Output is correct
17 Correct 8 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 8796 KB Output is correct
5 Correct 3 ms 10704 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 4 ms 10844 KB Output is correct
9 Correct 2 ms 8796 KB Output is correct
10 Correct 4 ms 10844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 4 ms 10840 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 3 ms 8800 KB Output is correct
5 Correct 4 ms 10692 KB Output is correct
6 Correct 1 ms 2500 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 1 ms 4596 KB Output is correct
10 Correct 8 ms 10844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2648 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Execution timed out 1068 ms 10844 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2400 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2400 KB Output is correct
8 Correct 1 ms 2500 KB Output is correct
9 Execution timed out 1022 ms 11096 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Runtime error 121 ms 35432 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -