Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ASMx64-2018 Nič nas ne sme presenetiti! C++ 0/100Prekoračen čas (TLE) 19. apr '18 @ 16:40

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 5,617 MiB 0,010 s OK
#2 12/12 5,477 MiB 0,172 s OK
#3 12/12 5,488 MiB 0,010 s OK
#4 12/12 9,078 MiB 0,296 s OK
#5 13/13 5,477 MiB 0,004 s OK
#6 13/13 8,531 MiB 0,488 s OK
#7 13/13 8,633 MiB 1,409 s OK
#8 0/13 8,871 MiB 6,669 s Prekoračen čas

Ocenjevani program (NNNP.cpp):
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

#define SIZE 100001 

vector<int> adj[SIZE];
bool obiskano[SIZE];
vector<int> uporniki;
bool jeUpornik[SIZE];
bool OK;


void DFS(int v) {
	obiskano[v] = true;

	for (int i = 0; i < adj[v].size(); i++) {
		if (jeUpornik[adj[v][i]] && !obiskano[adj[v][i]])
			DFS(adj[v][i]);
	}


	return;
}

int main() {
	int N, Q, a,b, M;

	cin >> N >> Q;

	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	for (int i = 0; i < Q; i++) {
		uporniki.clear();
		memset(obiskano, false, sizeof obiskano);
		memset(jeUpornik, false, sizeof jeUpornik);
		OK = true;
	
		cin >> M;
		for (int j = 0; j < M; j++) {
			cin >> a;
			uporniki.push_back(a);
			
			jeUpornik[a] = true;
		}

		DFS(uporniki[0]);
		for (int j = 0; j < M; j++) {
			if (!obiskano[uporniki[j]]) OK = false;
		}
		if (OK) cout << "ALAAAARHM\n";
		else cout << "NASLEDNJI\n";
	}
	return 0;
}