답안 #61589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61589 2018-07-26T07:46:07 Z IOrtroiii Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
26 ms 5600 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

const int N = 1e5 + 5;

int n;
vector<int> G[N];
bool can[N], chosen[N];
int cur, need, cnt;
vector<int> ask;
bool egg[N];

void dfs(int u,int p) {
	if (cnt == need) return;
	if (can[u]) cnt++;
	ask.push_back(u); chosen[u] = 1;
	for (int v : G[u]) if (v != p) {
		dfs(v, u);
	} 
}

int findEgg(int N,vector<pair<int,int> > bridges) {
	n = N;
	for (int i = 1; i <= n; ++i) can[i] = 1;
	
	for (auto ed : bridges) {
		int u = ed.first, v = ed.second;
		G[u].push_back(v), G[v].push_back(u);
	}
	
	cur = n;
	
	while (cur != 1) {
		ask.clear(); 
		need = cur / 2; 
		for (int i = 1; i <= n; ++i) chosen[i] = 0;
		cnt = 0;
		dfs(1, 1);
		if (query(ask)) {
			for (int i = 1; i <= n; ++i) if (!chosen[i]) {
				can[i] = 0;
			}
			cur = need;
		}
		
		else {
			for (int v : ask) can[v] = 0;
			cur -= need;
		}
	}
	
	for (int i = 1; i <= n; ++i) if (can[i]) {
		return i;
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 5240 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 5392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 5600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -