Cod sursa(job #2534491)
Utilizator | Data | 30 ianuarie 2020 17:30:41 | |
---|---|---|---|
Problema | Asmax | Scor | 0 |
Compilator | py | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
N = 5
V = [0,-1,1,3,1,-1]
L = [[0],[2,3,4],[1],[1],[1,5],[4]]
viz = [0]*(N+1)
SMAX = 0
def DFS(L,V,viz,currentNode):
viz[currentNode] = 1
global S
S += V[currentNode]
global SMAX
if S > SMAX:
SMAX = S
for x in L[currentNode]:
if viz[x] == 0:
DFS(L,V,viz,x)
for i in range(1,6):
S = 0
DFS(L,V,viz,i)
print(SMAX)