Problem p03013 (python)

Fixed submission:
CONST = 1000000007

def noboru(n):
    a1 = 1
    a2 = 2
    ans = 0
    if (n == 0 or n == 1): return a1
    elif (n == 2): return a2
    else:
        for i in range(1, n-1):
            ans = a2 + a1
            a1 = a2
            a2 = ans
        return a2

def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))

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

CONST = 1000000007

def noboru(i, a2, a1):
    if (i == 0 or i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1, 2, 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos, 2, 1)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))

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

CONST = 1000000007

def noboru(i, a2, a1):
    if (i == 0 or i == 1):
        return a1 % CONST
    elif (i == 2):
        return a2 % CONST
    else:
        return noboru(i-1, (a2+a1) % CONST, a2 % CONST)


def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1, 2, 1)) % CONST
            pos = a[i] + 1
    ans = (ans * noboru(N - pos, 2, 1)) % CONST
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))
# print(noboru(10000, 2, 1))
# print(sys.getrecursionlimit())

Buggy submission (verdict: Runtime Error):
def noboru(i, a2, a1):
    if (i == 0 or i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans = (ans * noboru(a[i] - pos - 1, 2, 1)) % 1000000007
            pos = a[i] + 1
    ans = (ans * noboru(N - pos, 2, 1)) % 1000000007
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a))

Buggy submission (verdict: Runtime Error):
def noboru(i, a2, a1):
    if (i == 0 or i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    pos = 0
    for i in range(M):
        if (pos == a[i]):
            return 0
        else:
            ans *= noboru(a[i] - pos - 1, 2, 1)
            pos = a[i] + 1
    ans *= noboru(N - pos, 2, 1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a) % 1000000007)

Buggy submission (verdict: Runtime Error):
def noboru(i, a2, a1):
    if (i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    for i in range(M):
        if (i==0):
            if (a[i] == 1):
                ans *= 1
            else:
                ans *= noboru(a[i] -1, 2, 1)
        elif(a[i] == a[i-1] + 1):
            return 0
        elif(a[i] == a[i-1] + 2):
            ans *= 1
        else:    
            ans *= noboru(a[i] - a[i-1] -2, 2, 1)
    ans *= noboru(N - a[M-1] -1, 2, 1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a) % 1000000007)

Buggy submission (verdict: Runtime Error):
def noboru(i, a2, a1):
    if (i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1, 2, 1)
    if (M > 1):
        for i in range(1, M):
            if (a[i] == a[i-1]+1):
                return 0
            else:
                ans *= noboru(a[i] - a[i-1] -2, 2, 1)
    ans *= noboru(N - a[M-1] -1, 2, 1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
#A_i = list(map(int, input().split(" ")))
#B_i = list(map(int, input().split(" ")))
print(func(N, M, a) % 1000000007)
#print(noboru(100, 2, 1))

Buggy submission (verdict: Runtime Error):
def noboru(i, a2, a1):
    if (i == 1):
        return a1
    elif (i == 2):
        return a2
    else:
        return noboru(i-1, a2+a1, a2)


def func(N, M, a):
    ans = 1
    i = 0
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1,2,1)
    if (M > 1):
        for i in range(1, M):
            if (a[i] == a[i-1]+1):
                return 0
            else:
                ans *= noboru(a[i] - a[i-1] -2,2,1)
    ans *= noboru(N - a[i] -1,2,1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
print(func(N, M, a) % 1000000007)

Buggy submission (verdict: Runtime Error):
def noboru(m):
    if (m == 1):
        return 1
    elif (m == 2):
        return 2
    else:
        return noboru(m-1)+noboru(m-2)

def func(N, M, a):
    ans = 1
    i = 0
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1)
    if (M > 1):
        for i in range(1, M):
            if (a[i] == a[i-1]+1):
                return 0
            else:
                ans *= noboru(a[i] - a[i-1] -2)
    ans *= noboru(N - a[i] -1)
    return ans

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
#A_i = list(map(int, input().split(" ")))
#B_i = list(map(int, input().split(" ")))
print(func(N, M, a) % 1000000007)
#print(noboru(6))

Buggy submission (verdict: Runtime Error):
def noboru(m):
    if (m == 1):
        return 1
    elif (m == 2):
        return 2
    else:
        return noboru(m-1)+noboru(m-2)

def func(N, M, a):
    ans = 1
    i = 0
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1)
    if (M > 1):
        for i in range(1, M):
            if (a[i] == a[i-1]+1):
                return 0
            else:
                ans *= noboru(a[i] - 2 - a[i-1])
    ans *= noboru(N - 1 - a[i])
    return ans % 1000000007

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
#A_i = list(map(int, input().split(" ")))
#B_i = list(map(int, input().split(" ")))
print(func(N, M, a))
#print(noboru(6))

Buggy submission (verdict: Runtime Error):
def noboru(m):
    if (m == 1):
        return 1
    elif (m == 2):
        return 2
    else:
        return noboru(m-1)+noboru(m-2)

def func(N, M, a):
    ans = 1
    if (a[0] == 1):
        ans *=1
    else:
        ans *= noboru(a[0]-1)
    for i in range(1, M):
        if (a[i] == a[i-1]+1):
            return 0
        else:
            ans *= noboru(a[i] - 2 - a[i-1])
    ans *= noboru(a[M] - 1 - a[i])
    return ans % 1000000007

N, M = map(int, input().split(" "))
a = [int(input()) for _ in range(M)]
a.append(N)
print(func(N, M, a))