Problem p03013 (python)

Fixed submission:
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
if m == 0:
    a.append(-1)
j = 0
k = len(a)-1
if 1 == a[j]:
    dp.append(0)
    j = min(k,j+1)
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j = min(k,j+1)
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
j = 0
k = len(a)-1
if 1 == a[j]:
    dp.append(0)
    j = min(k,j+1)
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j = min(k,j+1)
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
j = 0
if 1 == a[j]:
    dp.append(0)
    j += 1
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j += 1
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int,input().split())
a = []
pam = -1

def fib(k):
    if k<0:
        return 0
    r=(((1+math.sqrt(5))/2)**(k+1)-((1-math.sqrt(5))/2)**(k+1))/math.sqrt(5)
    return round(r)


for i in range(0,m):
    am = int(input())
    a.append(am-pam)
    pam = am
a.append(n+1-pam)
count = 1
for aa in a:
    count = count * (fib(aa-2))%(1000000007)
print(count%(1000000007))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n, m = map(int,input().split())
a = []
pam = -1

fibk={}
def fib(k):
    if k in fibk:
        return fibk[k]
    if k<0:
        return 0
    elif k==0 or k==1:
        return 1
    elif k-2 in fibk and not(k-1 in fibk):
        return fib(k-1)+fibk[k-2]
    elif k-2 in fibk and k-1 in fibk:
        return fibk[k-1]+fibk[k-2]
    else:
        return fib(k-1)+fib(k-2)


for i in range(0,m):
    am = int(input())
    a.append(am-pam)
    pam = am
a.append(n+1-pam)
count = 1
for aa in a:
    count = count * (fib(aa-2))%(1000000007)
print(count%(1000000007))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = []
pam = -1

fibk={}
def fib(k):
    if k in fibk:
        return fibk[k]
    if k<0:
        return 0
    elif k==0 or k==1:
        return 1
    elif k-2 in fibk and not(k-1 in fibk):
        return fib(k-1)+fibk[k-2]
    elif k-2 in fibk and k-1 in fibk:
        return fibk[k-1]+fibk[k-2]
    else:
        return fib(k-1)+fib(k-2)


for i in range(0,m):
    am = int(input())
    a.append(am-pam)
    pam = am
a.append(n+1-pam)
count = 1
for aa in a:
    count = count * fib(aa-2)
print(count%(1000000007))

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = []
pam = -1


def fib(k):
    if k<0:
        return 0
    elif k==0 or k==1:
        return 1
    else:
        return fib(k-1)+fib(k-2)


for i in range(0,m):
    am = int(input())
    a.append(am-pam)
    pam = am
a.append(n+1-pam)
count = 1
for aa in a:
    count = count * fib(aa-2)
print(a)
print(count%(1000000007))