Problem p02689 (python)

Fixed submission:
import numpy as np
 
n,m = input().split(" ")
n = int(n)
m = int(m)
 
H = input().split(" ")
H = np.array([int(h) for h in H])
Hs = np.zeros(n)

for i in range(m):
    a, b = input().split(" ")
    a = int(a) - 1
    b = int(b) - 1
    Hs[a] = np.max([Hs[a], H[b]])
    Hs[b] = np.max([Hs[b], H[a]])
 
G = []
for i in range(n):
    if Hs[i] < H[i]:
        G += [i]
 
print(len(G))

Buggy submission (verdict: Runtime Error):
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

M = np.zeros((n,n))
for i in range(m):
    a, b = input().split(" ")
    M[int(a)-1, int(b)-1] = 1
    M[int(b)-1, int(a)-1] = 1

G = []
for i in range(n):
    if sum(M[i, :]==1)==0:
        G += [i]
    else:
        if (np.max(H[M[i,:]==1]) < H[i]):
            G+= [i]

print(len(G))

Buggy submission (verdict: Runtime Error):
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

M = np.zeros((n,n))
for i in range(m):
    a, b = input().split(" ")
    M[int(a)-1, int(b)-1] = 1
    M[int(b)-1, int(a)-1] = 1

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        if (np.max(H[connected]) < H[i]):
            G+= [i]

print(len(G))

Buggy submission (verdict: Runtime Error):
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

M = np.zeros((n,n))
for i in range(m):
    a, b = input().split(" ")
    M[int(a)-1, int(b)-1] = 1
    M[int(b)-1, int(a)-1] = 1

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 0:
            G+= [i]

print(len(G))

Buggy submission (verdict: Runtime Error):
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

M = np.zeros((n,n))
for i in range(m):
    a, b = input().split(" ")
    M[int(a)-1, int(b)-1] = 1
    M[int(b)-1, int(a)-1] = 1

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 0:
            G+= [i]

print(len(G))

Buggy submission (verdict: Runtime Error):
import numpy as np

n,m = input().split(" ")
n = int(n)
m = int(m)

H = input().split(" ")
H = np.array([int(h) for h in H])

M = np.zeros((n,n))
for i in range(m):
    a, b = input().split(" ")
    M[int(a)-1, int(b)-1] = 1
    M[int(b)-1, int(a)-1] = 1

G = []
for i in range(n):
    # no path
    if sum(M[i,:])==0:
        G += [i]
    else:
        connected = np.where(M[i, :]==1)[0]
        flag = 0
        for c in connected:
            if (H[c] >= H[i]):
                flag  = 1
                break
        if flag == 1:
            G+= [i]

print(len(G))