Submission #115980

# Submission time Handle Problem Language Result Execution time Memory
115980 2019-06-10T06:09:42 Z HungAnhGoldIBO2020 Easter Eggs (info1cup17_eastereggs) C++11
100 / 100
17 ms 468 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
const int M=515;
bool used[M];
vector<int> lis,adj[M],lis1;
int now,dem;
bool cac;
void dfs(int x,int p){
	lis.push_back(x);
	if(!used[x]){
		lis1.push_back(x);
		dem++;
		if(dem==now/2){
			cac=true;
			return;
		}
	}
	int j=adj[x].size();
	for(int i=0;i<j;i++){
		if(cac){
			return;
		}
		if(adj[x][i]!=p){
			dfs(adj[x][i],x);
		}
	}
}
int findEgg(int N,vector<pair<int,int> > bridges){
	memset(used,false,sizeof(used));
	int i,j;
	for(i=1;i<M;i++){
		adj[i].clear();
	}
	j=bridges.size();
	for(i=0;i<j;i++){
		adj[bridges[i].first].push_back(bridges[i].second);
		adj[bridges[i].second].push_back(bridges[i].first);
	}
	now=N;
	while(now>1){
		dem=0;
		lis.clear();
		lis1.clear();
		cac=false;
		dfs(1,1);
		if(query(lis)==1){
			for(i=1;i<=N;i++){
				used[i]=true;
			}
			j=lis1.size();
			for(i=0;i<j;i++){
				used[lis1[i]]=false;
			}
			now=dem;
		}
		else{
			j=lis1.size();
			for(i=0;i<j;i++){
				used[lis1[i]]=true;
			}
			now=now-dem;
		}
	}
	for(i=1;i<=N;i++){
		if(!used[i]){
			return i;
		}
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Number of queries: 4
2 Correct 3 ms 256 KB Number of queries: 4
3 Correct 2 ms 256 KB Number of queries: 4
4 Correct 2 ms 256 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Number of queries: 8
2 Correct 14 ms 384 KB Number of queries: 9
3 Correct 14 ms 256 KB Number of queries: 9
4 Correct 12 ms 468 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 16 ms 268 KB Number of queries: 9
2 Correct 14 ms 384 KB Number of queries: 9
3 Correct 17 ms 256 KB Number of queries: 9
4 Correct 14 ms 256 KB Number of queries: 9