Problem p02689 (python)

Fixed submission:
import numpy as np
N,M=map(int,input().split())
S=np.ones(N)
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1]=0

  elif H[a-1]>H[b-1]:
    S[b-1]=0

  else:
    S[a-1]=0
    S[b-1]=0

print(int(np.sum(S)))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N+10):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))
print(S)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))

Buggy submission (verdict: Runtime Error):
mport numpy as np
N,M=map(int,input().split())
S=np.zeros((N,N))
H=list(map(int,input().split()))

for j in range(M):
  a,b=map(int,input().split())
  
  if H[a-1]<H[b-1]:
    S[a-1,b-1]=-1
    S[b-1,a-1]=1
  elif H[a-1]>H[b-1]:
    S[a-1,b-1]=1
    S[b-1,a-1]=-1
  else:
    S[a-1,b-1]=-1
    S[b-1,a-1]=-1

s=np.zeros(N)
for k in range(N):
  s[k]=np.any(S[k,:]<0)

print(len([i for i,x in enumerate(s) if x==0]))