답안 #243015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243015 2020-06-30T07:40:48 Z Exile_2k4 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
400 ms 5760 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
const int sz = 1e5+7;
 
#define pii pair<int,int>
 
vector<int> g[sz], call;
int need;
 
bool exist[sz], nxt[sz];
 
void dfs(int p,int u){
	if(exist[u] && call.size()<need) call.push_back(u);
	for(auto v:g[u]) if(v!=p) dfs(u,v);
}

//int query(vector<int> e){
//	for(auto v:e) cout << v << " ";
//	cout << endl;
//	int verd;
//	cin >> verd;
//	return verd;
//}
 
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){
		need = (cnt+1)/2;
		call.clear();
		dfs(1,1);
      	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;
}

//signed main(){
//	int n;
//	cin >> n;
//	vector<pii> e(n-1);
//	for(int i=0;i<n-1;++i) cin >> e[i].first >> e[i].second;
//	cout << findEgg(n,e);
//}

Compilation message

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:16: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:51:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3067 ms 2816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 5760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3057 ms 2944 KB Time limit exceeded
2 Halted 0 ms 0 KB -