Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * (N + 1)
n[0] = 1
n[1] = 1

#listの中をinで探すのはくっそ遅い
if 1 in a:
    n[1] = 0

for i in range(2, N + 1):
    if i in a:
        continue
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1
if 2 in a:
    n[1] = 0

for i in range(2, N):
    if i + 1 in a:
        continue
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1
if 2 in a:
    n[1] = 0

for i in range(2, N):
    if i + 1 in a:
        pass
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1
if 2 in a:
    n[1] = 0

for i in range(2, N):
    if i + 1 in a:
        pass
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1
if 2 in a:
    n[1] = 0

for i in range(2, N):
    if i + 1 in a:
        pass
    else:
        n[i] = (n[i - 1] + n[i - 2]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1
if 2 in a:
    n[1] = 0

for i in range(N - 2):
    if i + 3 in a:
        pass
    else:
        n[i + 2] = (n[i + 1] + n[i]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if N == 1:
    print(1)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1

for i in range(N - 2):
    if i + 3 in a:
        pass
    else:
        n[i + 2] = (n[i + 1] + n[i]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])
n = [0] * N
n[0] = 1
n[1] = 2

#listの中をinで探すのはくっそ遅い
if 1 in a and N == 1:
    print(0)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1

for i in range(N - 2):
    if i + 3 in a:
        pass
    else:
        n[i + 2] = (n[i + 1] + n[i]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = set(map(int, input().split()))
n = [0] * N
n[0] = 1
n[1] = 2

if 1 in a and N == 1:
    print(0)
    exit()
if 1 in a and 2 in a:
    print(0)
    exit()
if 1 in a:
    n[0] = 0
    n[1] = 1

for i in range(N - 2):
    if i + 3 in a:
        pass
    else:
        n[i + 2] = (n[i + 1] + n[i]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = [0] * N
n[0] = 1
n[1] = 2

if 1 in a and N == 1:
    print(0)
    exit()
if 1 in a and 2 in a:
    print(0)
if 1 in a:
    n[0] = 0
    n[1] = 1

for i in range(N - 2):
    if i + 3 not in a:
        n[i + 2] = (n[i + 1] + n[i]) % 1000000007

print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = [0] * N
n[0] = 1
n[1] = 2

if 1 in a and N == 1: print(0), exit()

for i in range(N - 2):
    if i + 3 not in a:
        n[i + 2] = n[i + 1] + n[i]
print(n[N - 1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = 1
a.insert(0, -1)
a.append(N + 1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def v(x):
    if x == -1:
        return 1
    else:
        q = x // 2
        r = x % 2
        ans = 0
        for i in range(x // 2 + 1):
            ans += cmb(q + r, r)
            r = r + 2
            q = q - 1
        return ans
for i in range(M + 1):
    if a[i + 1] - a[i] == 1:
        print(0)
        exit()

for i in range(M + 1):
    n = n * v((a[i + 1] - 1) - (a[i] + 1)) % 1000000007

print(n)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = 1
a.insert(0, -1)
a.append(N + 1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def v(x):
    if x == -1:
        return 1
    else:
        q = x // 2
        r = x % 2
        ans = 0
        for i in range(x // 2 + 1):
            ans += cmb(q + r, r)
            r = r + 2
            q = q - 1
        return ans
for i in range(M + 1):
    if a[i + 1] - a[i] == 1:
        print(0)
        exit()

for i in range(M + 1):
    n *= v((a[i + 1] - 1) - (a[i] + 1))  % 1000000007

print(n)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
n = 1
a.insert(0, -1)
a.append(N + 1)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

def v(x):
    if x == -1:
        return 1
    else:
        q = x // 2
        r = x % 2
        ans = 0
        for i in range(x // 2 + 1):
            ans += cmb(q + r, r)
            r = r + 2
            q = q - 1
        return ans
for i in range(M + 1):
    if a[i + 1] - a[i] == 1:
        print(0)
        exit()

for i in range(M + 1):
    n *= v((a[i + 1] - 1) - (a[i] + 1))

print(n % 1000000007)