Problem p03013 (python)

Fixed submission:
N,M = map(int, input().split())

a = [int(input()) for i in range(M)]

#初期化
dp=[-1]*N
dp[0]=1

for i in a:
    dp[i-1] = 0

for i in range(1,N):
    if dp[i]==0:
        continue
    elif i==1:
        dp[i]=dp[i-1] + 1
    else:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[N-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())

a = [int(input()) for i in range(M)]

#初期化
dp=[-1]*N
dp[0]=1

for i in a:
    dp[i-1] = 0

dp[1]=dp[0]+1
for i in range(2,N):
    if dp[i]==0:
        continue
    else:
        dp[i]=dp[i-1]+dp[i-2]

print(dp[N-1]%1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

N,M = map(int,input().split())

list=[]
for i in range(M):
    list.append(int(input()))

for i in range(1,len(list)):
    if list[i]-list[i-1] == 1:
        print(0)
        exit()

num_list = []
rest = N
cnt = 0

if M == 0:
    num_list.append(N+1)
else:
    list.sort(reverse = True)
    rest = N + 1
    for i in list:
        num_list.append(rest - i - 1)
        rest = i
    num_list.append(list[-1])

ans = 1
for i in num_list:
    ans = ans * Fib(i+1)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

N,M = map(int,input().split())

list=[]
for i in range(M):
    list.append(int(input()))

for i in range(1,len(list)):
    if list[i]-list[i-1] == 1:
        print(0)
        exit()

num_list = []
rest = N
cnt = 0

if M == 0:
    num_list.append(N+1)
else:
    list.sort(reverse = True)
    rest = N + 1
    for i in list:
        num_list.append(rest - i - 1)
        rest = i
    num_list.append(list[-1])

ans = 1
for i in num_list:
    ans = ans * Fib(i+1)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

N,M = map(int,input().split())

list=[]
for i in range(M):
    list.append(int(input()))

for i in range(1,len(list)):
    if list[i]-list[i-1] == 1:
        print(0)
        exit()

num_list = []
rest = N
cnt = 0

if M == 0:
    num_list.append(N+1)
else:
    list.sort(reverse = True)
    rest = N + 1
    for i in list:
        num_list.append(rest - i - 1)
        rest = i
    num_list.append(list[-1])

ans = 1
for i in num_list:
    ans = ans * Fib(i+1)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

N,M = map(int,input().split())

list=[]
for i in range(M):
    list.append(int(input()))

for i in range(1,len(list)):
    if list[i]-list[i-1] == 1:
        print(0)
        exit()

num_list = []
rest = N
cnt = 0

list.sort(reverse = True)
rest = N + 1
for i in list:
    num_list.append(rest - i - 1)
    rest = i
num_list.append(list[-1])

ans = 1
for i in num_list:
    ans = ans * Fib(i+1)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)

N,M = map(int,input().split())

list=[]
for i in range(M):
    list.append(int(input()))

for i in range(1,len(list)):
    if list[i]-list[i-1] == 1:
        print(0)
        exit()

num_list = []
rest = N
cnt = 0
for i in range(N+1):
    if i in list:
        num_list.append(cnt)
        cnt = 0
    elif i == N:
        num_list.append(cnt + 1)
    else:
        cnt += 1

ans = 1
for i in num_list:
    ans = ans * Fib(i+1)
print(ans % 1000000007)