Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
#A = [int(input()) for i in range(M)]
flag = [0]*N
for i in range(M):
    flag[int(input())-1] = 1
#A = [i*3 for i in range(N//3)]
#for i in range(N//3):
    #flag[i] = 1

mod = 10**9+7

dp = [0] * N

if flag[0]==0:
#if 1 not in A:
    dp[0] = 1
    if N>1:
        if flag[1]==0:
    #if (2 not in A) and N > 1:
            dp[1] = 2
elif N > 1:
    if flag[1]==0:
    #if 2 not in A:
        dp[1] = 1
    else:
        dp[1] = 0

loop = []
'''
for i in range(2, N):
    if i not in A:
        loop.append(i)
'''
for i in range(2, N):
    if flag[i]==0:
        dp[i] = (dp[i-2] + dp[i-1]) % mod
        #dp[i] = (sum(dp[i-2:i])) % mod

print(dp[N-1])
#print(dp)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
#A = [int(input()) for i in range(M)]
flag = [0]*N
for i in range(M):
    flag[int(input())-1] = 1
#A = [i*3 for i in range(N//3)]
#for i in range(N//3):
    #flag[i] = 1

mod = 10**9+7

dp = [0] * N

if flag[0]==0:
#if 1 not in A:
    dp[0] = 1
    if flag[1]==0 and N>1:
    #if (2 not in A) and N > 1:
        dp[1] = 2
elif N > 1:
    if flag[1]==0:
    #if 2 not in A:
        dp[1] = 1
    else:
        dp[1] = 0

loop = []
'''
for i in range(2, N):
    if i not in A:
        loop.append(i)
'''
for i in range(2, N):
    if flag[i]==0:
        dp[i] = (dp[i-2] + dp[i-1]) % mod
        #dp[i] = (sum(dp[i-2:i])) % mod

print(dp[N-1])
#print(dp)

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache
sys.setrecursionlimit(100001)

N, M = map(int, input().split())
b = tuple([int(input()) for i in range(M)])

mod = 10**9+7

@lru_cache(maxsize=None)
def Fib(n, a):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif (n-2 in a) and n!=0:
        return 0
    else:
        return (Fib(n-1, a) + Fib(n-2, a)) % mod

print(Fib(N+2, b))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N, M = map(int, input().split())
b = tuple([int(input()) for i in range(M)])

mod = 10**9+7

@lru_cache(maxsize=None)
def Fib(n, a):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif (n-2 in a) and n!=0:
        return 0
    else:
        return (Fib(n-1, a) + Fib(n-2, a)) % mod

print(Fib(N+2, b))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N, M = map(int, input().split())
b = tuple([int(input()) for i in range(M)])

mod = 10**9+7

@lru_cache(maxsize=None)
def Fib(n, a):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n-2 in a:
        return 0
    else:
        return (Fib(n-1, a) + Fib(n-2, a)) % mod

print(Fib(N+2, b))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N, M = map(int, input().split())
b = tuple([int(input()) for i in range(M)])

mod = 10**9+7

@lru_cache(maxsize=None)
def Fib(n, a):
    if n-2 in a:
        return 0
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return (Fib(n-1, a) + Fib(n-2, a)) % mod

print(Fib(N+2, b))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for i in range(M)]

mod = 10**9+7
dp = [0] * N
if 1 not in A:
    dp[0] = 1
    if 2 not in A:
        dp[1] = 2
elif 2 not in A:
    dp[1] = 1
else:
    dp[1] = 0

for i in range(2, N):
    if i+1 not in A:
        dp[i] = (dp[i-2] + dp[i-1]) % mod

print(dp[N-1])