Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)


N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[] for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
G = [[] * N for i in range(N)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    if w % 2 == 0:
        G[u-1].append((v-1, 1))
        G[v-1].append((u-1, 1))
    else:
        G[u-1].append((v-1, -1))
        G[v-1].append((u-1, -1))

color = [None for i in range(N)]


def set_color(v, c):
    color[v] = c
    for next_v, d in G[v]:
        if color[next_v] is None:
            set_color(next_v, d*c)


set_color(0, 1)

for c in color:
    if c == 1:
        print(1)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)

if N==1:
    print(1)
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    # G2 = csgraph_from_dense(G, null_value=10**12)
    # d = dijkstra(G2, indices=0)

    # for dist in d:
    #     if dist % 2 == 0:
    #         print(1)
    #     else:
    #         print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)

if N==1:
    print(1)
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    # G2 = csgraph_from_dense(G, null_value=10**12)
    # d = dijkstra(G2, indices=0)

    for dist in d:
        if dist % 2 == 0:
            print(1)
        else:
            print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)

if N==1:
    print(1)
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    G2 = csgraph_from_dense(G, null_value=10**12)
    d = dijkstra(G2, indices=0)

    # for dist in d:
    #     if dist % 2 == 0:
    #         print(1)
    #     else:
    #         print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)

if N==1:
    print(1)
else:
    for i in range(N-1):
        u, v, w = map(int, input().split())
        G[u-1][v-1] = w
        G[v-1][u-1] = w

    G2 = csgraph_from_dense(G, null_value=10**12)
    d = dijkstra(G2, indices=0)

    for dist in d:
        if dist % 2 == 0:
            print(1)
        else:
            print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)


for i in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1][v-1] = w
    G[v-1][u-1] = w

G2 = csgraph_from_dense(G, null_value=10**12)
d = dijkstra(G2, indices=0)

for dist in d:
    if dist % 2 == 0:
        print(1)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import dijkstra
import numpy as np

N = int(input())

G = np.full((N, N), 10**12)


for i in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1][v-1] = w
    G[v-1][u-1] = w

G2 = csgraph_from_dense(G, null_value=10**12)
d = dijkstra(G, indices=0)

for dist in d:
    if dist % 2 == 0:
        print(1)
    else:
        print(0)