답안 #243008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243008 2020-06-30T07:21:55 Z Exile_2k4 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
400 ms 384 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
const int sz = 600;
 
#define pii pair<int,int>
 
vector<int> g[sz], call;
 
bool exist[sz], nxt[sz];
 
void dfs(int p,int u, int need){
	if(exist[u] && call.size()<need) call.push_back(u);
	for(auto v:g[u]) if(v!=p && exist[v]) dfs(u,v,need);
}
 
int findEgg(int N, vector<pii> bridges){
	for(int i=0;i<N-1;++i){
		g[bridges[i].first].push_back(bridges[i].second);
		g[bridges[i].second].push_back(bridges[i].first);
	}
	memset(exist,1,sizeof(exist));
	
	int cnt = N;
	while(cnt!=1){
		int mid = cnt/2;
		call.clear();
		for(int i=1;i<=N;++i) if(exist[i]){
			dfs(i,i,mid);
			break;
		}
      	memset(nxt,0,sizeof(nxt));
		if(query(call)){
			for(auto v:call) nxt[v] = 1;
            for(int i=1;i<=N;++i) exist[i] = nxt[i];
			cnt = call.size();
		}else{
			for(auto v:call) exist[v] = 0;
			cnt -= call.size();
		}
	}
	for(int i=1;i<=N;++i) if(exist[i]) return i;
}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int, int)':
eastereggs.cpp:15:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(exist[u] && call.size()<need) call.push_back(u);
                 ~~~~~~~~~~~^~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:45:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3073 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3063 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3075 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -