답안 #115950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115950 2019-06-10T03:13:33 Z nhimnam120 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
3 ms 512 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
vector<int> ask;
vector<int> adj[1005];
bool used[1005];
bool take[1005];
bool bad[1005];
int sz=0;
int cnt=0;
void dfs(int node, int fa)
{
	if(cnt==sz/2) return;
	if(used[node]==0)
	{
		cnt++;
	}
	ask.push_back(node);
	for(auto i:adj[node])
	{
		if(bad[i]!=0||i==fa) continue;
		dfs(i,node);
	}
}
 
int findEgg (int N, vector < pair < int, int > > bridges)
{
	ask.clear();
	memset(used, 0, sizeof(used));
	memset(bad, 0, sizeof(bad));
	for(int i=1; i<=N; i++)
	{
		adj[i].clear();
	}
	sz=N;
	for(auto i:bridges)
	{
		adj[i.first].push_back(i.second);
		adj[i.second].push_back(i.first);
	}
	while(true)
	{
		ask.clear();
		if(sz==1)
		{
			for(int i=1; i<=N; i++)
			{
				if(bad[i]==0&&used[i]==0)
				{
					return i;
				}
			}
		}
		else
		{
			cnt=0;
			dfs(1,1);
			if(query(ask)!=0)
			{
				sz=cnt;
				bool lay[1000];
				memset(lay, 0, sizeof(lay));
				for(auto i:ask)
				{
					lay[i]=1;
				}
				for(int i=1; i<=N; i++)
				{
					if(lay[i]==0)
					{
						bad[i]=true;
					}
				}
			}
			else
			{
				sz-=cnt;
				for(auto i:ask)
				{
					used[i]=true;
					bad[i]=true;
				}
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -