Submission #476264

# Submission time Handle Problem Language Result Execution time Memory
476264 2021-09-25T18:00:03 Z lovrot Easter Eggs (info1cup17_eastereggs) C++11
0 / 100
4 ms 456 KB
#include <bits/stdc++.h> 
#include "grader.h"

#define X first
#define Y second

using namespace std; 

vector<int> g[530];
vector<int> half;
vector<int> all; 
vector<int> help;

int have;
bool took[530];

void findHalf(int x){ 
	if(have == 0)
		return;

	took[x] = true;
	half.push_back(x);

	have--;
	for(int y : g[x]){ 
		if(took[y] == true) 
			continue;

		findHalf(y);
	}
} 

int findEgg (int N, vector< pair< int, int > > graf ){ 
	memset(took, 0, sizeof(took));

	for(int i = 0; i <= N; i++)
		g[i].clear();

	for(int i = 0; i < N - 1; i++){ 
		int x = graf[i].X;
		int y = graf[i].Y;

		g[x].push_back(y);
		g[y].push_back(x);
	
		if(!took[x]){ 
			all.push_back(x);
			took[x] = true; 
		}
		if(!took[y]){ 
		 	all.push_back(y);
		 	took[y] = true;
		}
	}
	
	memset(took, false, sizeof(took));

	while(all.size() > 1){ 
		have = N / 2;
		half.clear();

		findHalf(all[0]);

		bool ans = query(half);

		if(ans){ 
			N /= 2;
		}
		else{ 
			N = N - N / 2;
		}

		help.clear();
		for(int x : all){ 
			if(took[x] == ans)
				help.push_back(x);
		}

		all.clear();
		for(int x : help){
			took[x] = false;
			all.push_back(x);
		}
	}

	return all[0];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -