Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 9,238 MiB 0,000 s OK
#2 12/12 9,262 MiB 0,000 s OK
#3 12/12 9,246 MiB 0,000 s OK
#4 12/12 58,840 MiB 1,039 s OK
#5 13/13 9,234 MiB 0,000 s OK
#6 13/13 37,949 MiB 0,808 s OK
#7 13/13 39,379 MiB 1,677 s OK
#8 13/13 43,188 MiB 1,702 s OK

Ocenjevani program (nnnp.py):
from collections import deque, defaultdict

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

g = [set() for i in range(n + 1)]

for i in range(n - 1):
    a, b = map(int, input().split())
    g[a].add(b)
    g[b].add(a)

for __ in range(q):
    m, start, *mesta = map(int, input().split())

    mesta = set(mesta)

    visited = {}

    q = deque()
    q.append(start)
    visited[start] = True

    while q:
        a = q.popleft()

        sosedje = g[a] & mesta
        for sosed in sosedje:
            if not visited.get(sosed, False):
                q.append(sosed)
                visited[sosed] = True
    
    if sum(visited.values()) == m:
        print('ALAAAARHM')
    else:
        print('NASLEDNJI')