Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [-1]*(n+1)
for i in para:
    dp[i] = 0
for i in range(n+1):
    if  dp[i] != 0 :
        if i == 1 or i==0:
            dp[i] = 1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod



print("{}".format(dp[-1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7


dp = [-1]*(n+1)
dp[0] = 1
for i in para :
    dp[i] = 0

def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 

    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[1] = 0
                cnt += 1
            else : 
                dp[1] = 1
                cnt += 1
        else :
            if dp[cnt] != 0 :  
                dp[cnt] = (dp[cnt-1] + dp[cnt-2]) % mod
                cnt += 1
            else :
                cnt += 1
        return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]%mod))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [-1]*(n+1)
dp[0] = 1
for i in para :
    dp[i] = 0

def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 

    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[1] = 0
                cnt += 1
            else : 
                dp[1] = 1
                cnt += 1
        else :
            if dp[cnt] != 0 :  
                dp[cnt] = (dp[cnt-1] + dp[cnt-2]) % mod
                cnt += 1
            else :
                cnt += 1
        return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
 
import sys
sys.setrecursionlimit(100000)
 
dp = [1,0]
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 
 
    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[1] = 0
                cnt += 1
            else : 
                dp[1] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                a  = 0 
                dp[0] = dp[1]
                dp[1] = a
                cnt += 1
            else :
                
                a  = (dp[0] + dp[1]) % mod
                dp[0] = dp[1]
                dp[1] = a 
                cnt += 1
        return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [1,0]
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 

    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[1] = 0
                cnt += 1
            else : 
                dp[1] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                a  = 0 
                dp[0] = dp[1]
                dp[1] = a
                cnt += 1
            else :
                
                a  = (dp[0] + dp[1]) % mod
                dp[0] = dp[1]
                dp[1] = a 
                cnt += 1
        return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [0] * (n+1) 
dp[0] = 1
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 
    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[cnt] = 0
                cnt +=1
            else : 
                dp[cnt] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                dp[cnt] = 0 
                cnt += 1
            else :
                dp[cnt] = (dp[cnt-1] + dp[cnt-2])%mod
                cnt += 1
    return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [0] * (n+1) 
dp[0] = 1
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 
    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[cnt] = 0
                cnt +=1
            else : 
                dp[cnt] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                dp[cnt] = 0 
                cnt += 1
            else :
                dp[cnt] = dp[cnt-1] + dp[cnt-2]
                cnt += 1
    return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]%mod))