Rezultati

Up. imeNalogaJezikRezultatČas oddaje
muzik-2018 Nič nas ne sme presenetiti! Python 3 100/100OK 19. apr '18 @ 16:46

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 8,652 MiB 0,000 s OK
#2 12/12 8,656 MiB 0,000 s OK
#3 12/12 8,648 MiB 0,000 s OK
#4 12/12 38,020 MiB 0,662 s OK
#5 13/13 8,656 MiB 0,000 s OK
#6 13/13 27,512 MiB 0,462 s OK
#7 13/13 28,453 MiB 1,219 s OK
#8 13/13 29,531 MiB 1,209 s OK

Ocenjevani program (nnnp.py):
import sys

#sys.stdin = open("mesta.in")

inp = sys.stdin.readline
N, q = map(int, inp().split())


graph = [[] for j in range(N)]
visited = [-1 for j in range(N)]

def investigate(cits, lev):
    k = len(cits)
    if k == 1:
        return 1
    citss = set(cits)
    stack = [cits.pop()]
    visited[stack[0]] = lev
    tried = 1
    while stack:
        top = stack.pop()
        visited[top] = lev
        for j in graph[top]:
            if visited[j] != lev and j in citss:
                stack.append(j)
                tried += 1
                if tried == k:
                    return 1
    return 0



for j in range(N-1):
    b, e = map(int, inp().split())
    graph[b-1].append(e-1)
    graph[e-1].append(b-1)

for j in range(q):
    _, *cits = map(int, inp().split(" "))
    cits = [j-1 for j in cits]
    aa = investigate(cits,j)
    if aa:
        print("ALAAAARHM")
    else:
        print("NASLEDNJI")