Rezultati

Up. imeNalogaJezikRezultatČas oddaje
cimetovipolzki-2018 Nič nas ne sme presenetiti! Python 3 0/100Prekoračen čas (TLE) 19. apr '18 @ 17:49

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 9,207 MiB 0,000 s OK
#2 12/12 10,645 MiB 0,000 s OK
#3 12/12 9,039 MiB 0,000 s OK
#4 12/12 57,242 MiB 1,344 s OK
#5 13/13 9,203 MiB 0,000 s OK
#6 0/13 52,465 MiB 20,050 s Prekoračen čas
#7 0/13 59,938 MiB 24,810 s Prekoračen čas
#8 0/13 60,246 MiB 7,894 s Prekoračen čas

Ocenjevani program (pogani.py):
from collections import deque

n, q = map(int, input().strip().split())


povezave = [list(map(int, input().strip().split())) for _ in range(n-1)]

sosedi = [[] for i in range(n)]
for a, b in povezave:
    sosedi[a-1].append(b-1)
    sosedi[b-1].append(a-1)


uporniki = [list(map(int, input().strip().split())) for _ in range(q)]

def preveri_podgraf(upor, graf):
    m = upor[0]
    visited = [False] * n
    zanimivi = [False] * n
    for j in upor[1:]:
        zanimivi[j-1] = True
    sum = 0

    stack = deque()
    stack.append(upor[1] - 1)
    while stack:
        a = stack.pop()
        for i in graf[a]:
            if not visited[i] and zanimivi[i]:
                stack.append(i)
        visited[a] = True
        sum += 1
    return sum == m

for u in uporniki:
    if preveri_podgraf(u, sosedi):
        print("ALAAAARHM")
    else:
        print("NASLEDNJI")