Problem:


Score : 300 points

Problem Statement

There are N people, conveniently numbered 1 through N.
They were standing in a row yesterday, but now they are unsure of the order in which they were standing.
However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person.
According to their reports, the difference above for person i is A_i.

Based on these reports, find the number of the possible orders in which they were standing.
Since it can be extremely large, print the answer modulo 10^9+7.
Note that the reports may be incorrect and thus there may be no consistent order.
In such a case, print 0.

Constraints

1≦N≦10^5

0≦A_i≦N-1

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 ... A_N

Output

Print the number of the possible orders in which they were standing, modulo 10^9+7.

Sample Input 1

5
2 4 4 0 2

Sample Output 1

4

There are four possible orders, as follows:

2,1,4,5,3

2,5,4,1,3

3,1,4,5,2

3,5,4,1,2

Sample Input 2

7
6 4 0 2 4 0 2

Sample Output 2

0

Any order would be inconsistent with the reports, thus the answer is 0.

Sample Input 3

8
7 5 1 1 7 3 5 3

Sample Output 3

16



Sample input:
5
2 4 4 0 2


Sample output:
4

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def maybe_check(n,A):
    try:
        if n <= 0 or n >= 10000:
            raise

        if len(A) <= 0 or len(A) > n:
            raise

        div = 10 ** 9 + 7
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]
        pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

        for i in A:
            if i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

def get_num(size):
    lst = []
    maxIndex = size-1
    for i in xrange(size):
        lst.append(abs(i-(maxIndex-i)))

    return lst

def check_elem_cnt(aset, alst, blst):
    cnt_lst = [0] * len(alst)
    #パフォーマンス的にダメだった実装
    #for x in aset:
    #    acnt = alst.count(x)
    #    bcnt = blst.count(x)

    #    if acnt != bcnt:
    #        return False

    for x in alst:
        cnt_lst[x] += 1

    alst_size = len(alst)
    if alst_size % 2 != 0:
        if cnt_lst[0] != 1:
            return False
    else:
        if cnt_lst[0] != 0:
            return False

    for x in aset:
        if x == 0:
            continue
        if cnt_lst[x] != 2:
            return False

    return True

def is_same_elem(a, b):
    if len(a) == 1 and a[0] != 0:
        return False
    if len(a) != len(b):
        return False

    aset = set(a)
    bset = set(b)

    if aset != bset:
        return False

    return check_elem_cnt(aset, a, b)

def solve(lst):
    if len(lst) == 1 and lst[0] == 0:
        return 1

    aset = set(lst)
    size = len(aset)
    ans = 0

    if size % 2 == 0:
        ans = pow(size,2)
    else:
        ans = pow(size-1,2)

    return ans
    #sum = 0
    #for x in aset:
    #    if lst.count(x) == 2:
    #        sum += 1

    #return pow(sum,2)

def div(ans):
    elem = pow(10, 9) + 7
    return ans % elem

if __name__ == "__main__":
    size = int(raw_input())
    line = raw_input()
    inp_lst = map(int, line.split(' '))

    my_lst = get_num(size)

    if is_same_elem(inp_lst, my_lst):
        ans = solve(my_lst)
        print div(ans)
    else:
        print 0

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

def get_num(size):
    lst = []
    maxIndex = size-1
    for i in xrange(size):
        lst.append(abs(i-(maxIndex-i)))

    return lst

def check_elem_cnt(aset, alst, blst):
    cnt_lst = [0] * len(alst)
    #パフォーマンス的にダメだった実装
    #for x in aset:
    #    acnt = alst.count(x)
    #    bcnt = blst.count(x)

    #    if acnt != bcnt:
    #        return False

    for x in alst:
        cnt_lst[x] += 1

    alst_size = len(alst)
    if alst_size % 2 != 0:
        if cnt_lst[0] != 1:
            return False
    else:
        if cnt_lst[0] != 0:
            return False

    for x in aset:
        if x == 0:
            continue
        if cnt_lst[x] != 2:
            return False

    return True

def is_same_elem(a, b):
    if len(a) == 1 and a[0] != 0:
        return False
    if len(a) != len(b):
        return False

    aset = set(a)
    bset = set(b)

    return check_elem_cnt(aset, a, b)

def solve(lst):
    if len(lst) == 1 and lst[0] == 0:
        return 1

    aset = set(lst)
    size = len(aset)
    ans = 0

    if size % 2 == 0:
        ans = pow(size,2)
    else:
        ans = pow(size-1,2)

    return ans
    #sum = 0
    #for x in aset:
    #    if lst.count(x) == 2:
    #        sum += 1

    #return pow(sum,2)

def div(ans):
    elem = pow(10, 9) + 7
    return ans % elem

if __name__ == "__main__":
    size = int(raw_input())
    line = raw_input()
    inp_lst = map(int, line.split(' '))

    my_lst = get_num(size)

    if is_same_elem(inp_lst, my_lst):
        ans = solve(my_lst)
        print div(ans)
    else:
        print 0

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

def get_num(size):
    lst = []
    maxIndex = size-1
    for i in xrange(size):
        lst.append(abs(i-(maxIndex-i)))

    return lst

def check_elem_cnt(aset, alst, blst):
    cnt_lst = [0] * len(alst)
    #パフォーマンス的にダメだった実装
    #for x in aset:
    #    acnt = alst.count(x)
    #    bcnt = blst.count(x)

    #    if acnt != bcnt:
    #        return False

    for x in alst:
        cnt_lst[x] += 1

    alst_size = len(alst)
    if alst_size % 2 != 0:
        if cnt_lst[0] != 1:
            return False
    else:
        if cnt_lst[0] != 0:
            return False

    for x in aset:
        if x == 0:
            continue
        if cnt_lst[x] != 2:
            return False

    return True

def is_same_elem(a, b):
    if len(a) == 1 and a[0] != 0:
        return False
    if len(a) != len(b):
        return False

    aset = set(a)
    bset = set(b)

    return check_elem_cnt(aset, a, b)

def solve(lst):
    if len(lst) == 1 and lst[0] == 0:
        return 1

    aset = set(lst)
    size = len(aset)
    ans = 0

    if size % 2 == 0:
        ans = pow(size,2)
    else:
        ans = pow(size-1,2)

    return ans
    #sum = 0
    #for x in aset:
    #    if lst.count(x) == 2:
    #        sum += 1

    #return pow(sum,2)

def div(ans):
    elem = pow(10, 9) + 7
    return divmod(ans, elem)[1]

if __name__ == "__main__":
    size = int(raw_input())
    line = raw_input()
    inp_lst = map(int, line.split(' '))

    my_lst = get_num(size)

    if is_same_elem(inp_lst, my_lst):
        ans = solve(my_lst)
        print div(ans)
    else:
        print 0

Submission status: Wrong Answer

Solution code:
def get_num(size):
    lst = []
    maxIndex = size-1
    for i in xrange(size):
        lst.append(abs(i-(maxIndex-i)))

    return lst

def check_elem_cnt(aset, alst, blst):
    for x in aset:
        acnt = alst.count(x)
        bcnt = blst.count(x)

        if acnt != bcnt:
            return False

    return True

def is_same_elem(a, b):
    if len(a) != len(b):
        return False

    aset = set(a)
    bset = set(b)

    return check_elem_cnt(aset, a, b)

def solve(lst):
    aset = set(lst)
    sum = 0
    for x in aset:
        if lst.count(x) == 2:
            sum += 1

    return pow(sum,2)

def div(ans):
    elem = pow(10, 9) + 7
    return divmod(ans, elem)[1]

if __name__ == "__main__":
    size = int(raw_input())
    line = raw_input()
    inp_lst = map(int, line.split(' '))

    my_lst = get_num(size)

    if is_same_elem(inp_lst, my_lst):
        ans = solve(my_lst)
        print div(ans)
    else:
        print 0

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if num == 0:
            if cnt != 1:
                print(0)
                sys.exit()
        else:
            if not (num % 2 == 0 and cnt == 2):
                print(0)
                sys.exit()
    print(2 ** (N // 2))
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
N = input()
MOD = 10**9+7

memo = {0: 1, 1: 2}
def S(k):
    if k in memo:
        return memo[k]
    if k % 2 == 1:
        result = (2*S(k/2) + S(k/2-1)) % MOD
    else:
        result = (S(k/2) + 2*S(k/2-1)) % MOD
    memo[k] = result
    return result
print S(N)

Submission status: Wrong Answer

Solution code:
def get_possible(n, people):
    counts = {}
    values = set([])
    for person in people:
        if not counts.get(person):
            counts[person] = 1
            values.add(person)
        else:
            counts[person] += 1

    if n % 2:
        start_value = 0
    else:
        start_value = 1

    if values != set([i for i in xrange(start_value, n , 2)]):
        return 0

    possibilities = 1

    if 0 in values:
        values.remove(0)

    for key in list(values):
        if counts.get(key) != 2:
            print "a"
            return 0
        else:
            possibilities *= counts.get(key)

    return possibilities



if __name__ == "__main__":
    n = int(raw_input())
    people = map(int, raw_input().split(' '))
    print get_possible(n, people) % (10**9 + 7)

Submission status: Wrong Answer

Solution code:
def get_possible(n, people):
    counts = {}
    values = set([])
    for person in people:
        if not counts.get(person):
            counts[person] = 1
            values.add(person)
        else:
            counts[person] += 1

    # If even
    if n % 2:
        start_value = 0
    else:
        start_value = 1

    if values != set([i for i in xrange(start_value, n , 2)]):
        return 0

    possibilities = 1

    if 0 in values:
        values.remove(0)

    for key in list(values):
        if counts.get(key) != 2:
            return 0
        else:
            possibilities *= counts.get(key)

    return possibilities



if __name__ == "__main__":
    n = int(raw_input())
    people = map(int, raw_input().split(' '))
    print get_possible(n, people)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from collections import Counter
import sys
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7
A = Counter(A)

if N % 2 == 1:
    for num, cnt in A.items():
        # print(num, cnt)
        if (num == 0 and cnt != 1):
            print(0)
            sys.exit()
        elif not (num % 2 == 0 and cnt == 2):
            print(0)
            sys.exit()
    print(2 ** (N // 2))
else:
    for num, cnt in A.items():
        # print(num, cnt)
        if not (num % 2 == 1 and cnt == 2):
            print(0)
            sys.exit()
    print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
#!coding:utf-8

n = input()
a = [int(i) for i in raw_input().split()]
a.sort()

ok = True

if(n%2==0):
    for i in range(n):
        if(a[i]!=(i/2*2+1)):
            ok = False

if(n%2==1):
    for i in range(n):
        if(a[i]!=((i+1)/2*2)):
            ok = False


if(ok):
    print 2**(n/2)%10000007
        
else:
    print '0'

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()
if N % 2:
	B = [i for i in range(2,N,2)]*2
	B.sort()
	B.reverse()
	B.append(0)
else:
	B = [i for i in range(1,N,2)]*2
	B.sort()
	B.reverse()
if A == B:
	ans = 2**(N//2)
else:
	ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
a = map(int, raw_input().split())

x = []
if n % 2 == 0:
    for i in range(1, n, 2):
        x.extend([i, i])
else:
    x.append(0)
    for i in range(2, n, 2):
        x.extend([i, i])

for i in a:
    if i in x:
        x.remove(i)
    else:
        print 0
        break
else:
    if n % 2 == 0:
        print 2 ** (n/2)
    else:
        print 2 ** ((n-1)/2)

Submission status: Wrong Answer

Solution code:
n = input()
a = map(int, raw_input().split())
a = sorted(a)
c = 1
i = 0
if n%2 == 0:
    k = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**7
        i += 2
        k += 2
else:
    if not a[0] == 0:
        print 0
        exit()
    k = 2
    i = 1
    while i < len(a):
        if not a[i] == a[i+1] == k:
            print 0
            exit()
        c *= 2
        c %= 10**7
        i += 2
        k += 2
print c

Submission status: Wrong Answer

Solution code:
import collections

def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    ac = dict(collections.Counter(a))

    if n % 2 == 0:
        if 0 in ac:
            return 0
    else:
        if 0 not in ac or ac[0] != 1:
            return 0
        else:
            del ac[0]
    ans = 1

    for k, v in ac.items():
        if (k + n) % 2 == 1 and v == 2:
            ans *= 2
        else:
            return 0

    return ans

print(solve())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

n()
A = ln()

L = len(A)

A.sort()

if L % 2 == 1:
    c = A[0]
    del A[0]
    B = A[1::2][::-1] + [c] + A[0::2]
else:
    B = A[1::2][::-1] + A[0::2]

for i in xrange(L):
    j = L - i - 1
    if abs(i - j) != B[i]:
        print 0
        break
else:
    print 2 ** (len(A) / 2)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    ans = 0
    mod = 10**9+7
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        if (N-1-i)==i:
            if A.count(0)!=1:
                return 0
        else: 
            if A.count(abs((N-1-i)-i))!=2:
                return 0
    ans = pow(2,N//2,mod)
    return ans
print(solve())

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
    for i in range(n//2):
        if a.count(2*i + 1) != 2:
            print(0)
            exit()
else:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(1,n//2+1):
        if a.count(2*i) != 2:
            print(0)
            exit()
    
print(2**(n//2) % (10**9+7))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
ar.sort()
b = ar.count(0) 
if b >= 2:
    print(0)
    exit()
br = ar[b:a]
for r in set(br):
    if br.count(r) % 2 == 1:
        print(0)
        exit()
print(2 ** (len(br) // 2))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
b = 0
for r in set(ar):
    if r != 0:
        if ar.count(r) % 2 == 1:
            print(0)
            exit()
    if r == 0:
        a -= 1
print(2 ** (a // 2))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int,input().split()))
flag = True
if n%2 == 1:
    for i in range(0,n,2):
        if i == 0:
            if li.count(0) != 1:
                flag = False
        else:
            if li.count(i) != 2:
                flag = False
else:
    for i in range(1,n,2):
        if li.count(i) != 2:
            flag = False
if not flag:
    print(0)
    exit()

if n%2 == 1:
    print(2**((n-1)//2))
else:
    print(2**(n//2))

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
A_lis = list(input().split())
r = 10 ** 9 + 7
count = 2 ** (int(math.floor(N/2)))

for i in range(N):
    if N % 2 == i % 2:
        if A_lis.count(str(i)) != 0:
            count = 0
            break
        else:
            continue
    else:
        if i == 0:
            if A_lis.count(str(i)) == 1:
                continue
            else:
                count = 0
                break
        elif A_lis.count(str(i)) != 2:
            count = 0
            break
        else:
            continue
        
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A_lis = list(input().split())
count = 1
r = 10 ** 9 + 7

for i in range(N):
    if N % 2 == i % 2:
        if A_lis.count(str(i)) != 0:
            count = 0
            break
        else:
            continue
    else:
        if i == 0:
            if A_lis.count(str(i)) == 1:
                continue
            else:
                count = 0
                break
        elif A_lis.count(str(i)) != 2:
            count = 0
            break
        else:
            count = (count * 2) % r
            continue
        
print(count)

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
A = list(map(int,input().split()))

ans = 1
if N % 2 == 1 and A.count(0) != 1:
    ans = 0

if N % 2 == 1:
    A.remove(0)
    
c = -1
if N % 2 == 0:
    c = 1
else:
    c = 2

for i in range(c, N, 2):
    if A.count(i) != 2:
        ans = 0
    else:
        ans *= 2
        A.remove(i)
        A.remove(i)

if len(A) != 0:
    ans = 0

print(ans % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

if N % 2 == 1:
    for i in range(N // 2):
        if A.count(i * 2) != 2 and i != 0:
            print(0)
            exit()
        if i == 0 and A.count(i) != 1:
            print(0)
            exit()

if N % 2 == 0:
    for i in range(N // 2):
        if A.count(i * 2 + 1) != 2:
            print(0)
            exit()

print(2 ** (N // 2))

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    if(n % 2 == 0):
        for i in range(1, n, 2):
            if(a.count(i) != 2):
                print(0)
                exit(0)
        print(2**(n//2))
        exit(0)
    for i in range(0, n, 2):
        if(i == 0 and a.count(i) != 1):
            print(0)
            exit(0)
        elif(i != 0 and a.count(i) != 2):
            print(0)
            exit(0)
    print(2**(n//2))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
if N & 1:
    if A.count(0) == 1:
        for i in range(2,N,2):
            if A.count(i)!=2:
                print(0)
                exit()
    else:
        print(0)
        exit()
else:
    for i in range(1, N, 2):
        if A.count(i) != 2:
            print(0)
            exit()
print(pow(2, N//2, 10**9+7))

Submission status: Time Limit Exceeded

Solution code:
import sys


MOD = 1000000007

N = int(input())
a = list(map(int,input().split()))

if(N%2 == 0):
    for i in range(N//2):
        n = 2*i + 1
        if(a.count(n) != 2):
            print(0)
            sys.exit()
    print((2 ** (N//2)) % MOD)
else:
    if(a.count(0) != 1):
        print(0)
        sys.exit()
    for i in range((N-1)//2):
        n = 2*i + 2
        if(a.count(n) != 2):
            print(0)
            sys.exit()
    print((2 ** ((N-1)//2)) % MOD)

Submission status: Time Limit Exceeded

Solution code:
import sys

N = int(input())
a = list(map(int,input().split()))

if(N%2 == 0):
    a.sort()
    for i in range(N//2):
        n = 2*i + 1
        if(a.count(n) != 2):
            print(0)
            sys.exit()
    print(2 ** (N//2))
else:
    a.sort()
    if(a.count(0) != 1):
        print(0)
        sys.exit()

    for i in range((N-1)//2):
        n = 2*(i+1)
        if(a.count(n) != 2):
            print(0)
            sys.exit()
    print(2 ** ((N-1)//2))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7
ans = 0

if N % 2 == 0:
    for i in range(1, N, 2):
        if A.count(i) != 2:
            print(0)
            exit()
    print(2 ** (N // 2) % mod)
else:
    for i in range(2, N, 2):
        if A.count(i) != 2:
            print(0)
            exit()
    if A.count(0) != 1:
        print(0)
        exit()
    print(2 ** (N // 2) % mod)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

if N%2 == 0:
    for i in range(1,N,2):
        if A.count(i) != 2:
            print(0)
            exit()
else:
    if A.count(0) != 1:
        print(0)
        exit()
    for i in range(2,N,2):
        if A.count(i) != 2:
            print(0)
            exit()

p = N//2
print(2**p)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def resolve():
    n = int(stdin.readline().rstrip())
    # s = stdin.readline().rstrip()
    # A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]

    a = sorted(a)
    if n % 2 == 1:
        if a[0] != 0:
            return 0
        a = a[1:]

    predict = 1 + (n % 2)
    while len(a) > 0:
        if a[0] != predict or a[1] != predict:
            return 0
        a = a[2:]
        predict += 2

    ret = 1
    for i in range(0, n // 2):
        ret = (ret * 2) % 1000000007
    return ret


print(resolve(), '\n')
# print(*data, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(2, n, 2):
        if a.count(i) != 2:
            print(0)
            exit()
else:
    if a.count(1) != 2:
        print(0)
        exit()
    for i in range(1, n, 2):
        if i == 1:
            continue
        if a.count(i) != 2:
            print(0)
            exit()
mod = 10 ** 9 + 7
print((2 ** (n // 2)) % mod)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(2, n, 2):
        if a.count(i) != 2:
            print(0)
            exit()
else:
    if a.count(1) != 2:
        print(0)
        exit()
    for i in range(1, n, 2):
        if i == 1:
            continue
        if a.count(i) != 2:
            print(0)
            exit()
mod = 10 ** 9 + 7
ans = 1
for i in range(n // 2):
    ans = (ans % mod) * 2
print(ans % mod)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(2, n, 2):
        if a.count(i) != 2:
            print(0)
            exit()
else:
    if a.count(1) != 2:
        print(0)
        exit()
    for i in range(1, n, 2):
        if i == 1:
            continue
        if a.count(i) != 2:
            print(0)
            exit()
print(2 ** (n // 2))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(n):
        if i % 2 or i == 0:
            continue
        if a.count(i) != 2:
            print(0)
            exit()
else:
    if a.count(1) != 2:
        print(0)
        exit()
    for i in range(n):
        if i % 2 == 0 or i == 1:
            continue
        if a.count(i) != 2:
            print(0)
            exit()
print(2 ** (n // 2))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
lis = list(map(int,input().split()))
if n % 2 == 0:key = 1
else:key = 2
for i in range(n//2):
    if lis.count(i*2+key) != 2:
        print("0")
        exit()
if n % 2 == 1:
    if lis.count(0) != 1:
        print("0")
        exit()
print(2 ** (n//2))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
count = 1
if a % 2 == 1:
    for i in range(0,a,2):
        if i == 0:
            if ar.count(0) != 1:
                count = 0
                break
        else:
            if ar.count(i) != 2:
                count = 0
                break
            else:
                count *= 2
else:
    for i in range(1,a,2):
        if ar.count(i) != 2:
            count = 0
            break
        else:
            count *= 2
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))


def solve():
    for a in A:
        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            else:
                if a == 0 and A.count(a) != 1:
                    return 0
                elif a != 0 and A.count(a) != 2:
                    return 0
        else:
            if a % 2 == 0:
                return 0
            else:
                if A.count(a) != 2:
                    return 0
    return 2 ** (N // 2)


print(solve())

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 1:
    if a.count(0) > 1:
        print(0)
    else:
        a.remove(0)
        for i in list(set(a)):
            if a.count(i) != 2:
                print(0)
                exit()
        print(2 ** ((n - 1) // 2))
else:
    if a.count(0) > 0:
        print(0)
    else:
        for i in list(set(a)):
            if a.count(i) != 2:
                print(0)
                exit()
        print(2 ** (n // 2))

Submission status: Time Limit Exceeded

Solution code:
import math
from collections import Counter
n = int(input())
lis = list(map(str,input().split()))
if n % 2 == 1:
  for i in range(math.ceil(n / 2)):
    if i == 0:
      if lis.count("0") != 1:
        print("0")
        exit()
    else:
      if lis.count(str(i * 2)) != 2:
        print("0")
        exit()
  print(2 ** (math.floor(n/2)))
else:
  for i in range(n//2):
    if lis.count(str(i * 2 + 1)) != 2:
      print("0")
      exit()
  print(2 ** (n//2))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = list(map(int,input().split()))

if n % 2 == 0:
    b = 0
    for i in range(n//2):
        if a.count(i*2+1) != 2:
            b = 1
    if b == 1:
        print(0)
    else:
        print(2**(n//2))
else:
    b = 0
    if a.count(0) != 1:
        b = 1
    else:
        for i in range(n//2):
            if a.count((i+1)*2) != 2:
                b = 1
    if b == 1:
        print(0)
    else:
        print(2**(n//2))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
    count = 0
    for i in a:
        if a.count(i) == 2:
            count += 1
    if count == n:
        print(int(2**(n/2))%(10**9+7))
    else:
        print(0)
else:
    count = 0
    for i in a:
        if a.count(i) == 2:
            count += 1
    if count == n-1 and a.count(0) == 1:
        print(int(2**((n-1)/2))%(10**9+7))
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))

if n%2 == 0:
    count = 0
    for i in a:
        if a.count(i) == 2:
            count += 1
    if count == n:
        print(int(2**(n/2)))
    else:
        print(0)
else:
    count = 0
    for i in a:
        if a.count(i) == 2:
            count += 1
    if count == n-1 and a.count(0) == 1:
        print(int(2**((n-1)/2)))
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

report_list = [int(n) for n in input().split()]


def how_many_num_in_list(list, num):
    count = 0
    for element in list:
        if element == num:
            count += 1
    return count


# 同じ数字が２個ずつあるか
def is_ready_for_solve(list):
    if N % 2 == 0:
        c = 0
        for n in set(report_list):
            if how_many_num_in_list(report_list, n) == 2:
                c += 1
        if c == N / 2:
            return True
        else:
            return False

    else:
        c = 0
        for n in set(report_list):
            if n == 0:
                continue
            elif how_many_num_in_list(report_list, n) == 2:
                c += 1
        if c == (N - 1) / 2:
            return True
        else:
            return False


if N % 2 == 0:
    if how_many_num_in_list(report_list, 0) == 0:
        if is_ready_for_solve(report_list):
            print(int((2 ** (N / 2)) % (10 ** 9 + 7)))
        else:
            print(0)
    else:
        print(0)
else:
    if how_many_num_in_list(report_list, 0) == 1:
        if is_ready_for_solve(report_list):
            print(int((2 ** ((N - 1) / 2)) % (10 ** 9 + 7)))
        else:
            print(0)
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

report_list = [int(n) for n in input().split()]


def how_many_num_in_list(list, num):
    count = 0
    for element in list:
        if element == num:
            count += 1
    return count


# 同じ数字が２個ずつあるか
def is_ready_for_solve(list):
    if N % 2 == 0:
        c = 0
        for n in set(report_list):
            if how_many_num_in_list(report_list, n) == 2:
                c += 1
        if c == N / 2:
            return True
        else:
            return False

    else:
        c = 0
        for n in set(report_list):
            if n == 0:
                continue
            elif how_many_num_in_list(report_list, n) == 2:
                c += 1
        if c == (N - 1) / 2:
            return True
        else:
            return False


if N % 2 == 0:
    if how_many_num_in_list(report_list, 0) == 0:
        if is_ready_for_solve(report_list):
            print(int(2 ** (N / 2)))
        else:
            print(0)
    else:
        print(0)
else:
    if how_many_num_in_list(report_list, 0) == 1:
        if is_ready_for_solve(report_list):
            print(int(2 ** ((N - 1) / 2)))
        else:
            print(0)
    else:
        print(0)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(raw_input())
a = np.array(raw_input().strip().split(), dtype=int)
if n % 2 == 0:
    jj = True
    for i in range(1, n, 2):
        jj = jj and (len(np.where(a == i)[0]) == 2)
else:
    jj = True
    for i in range(0, n, 2):
        if i == 0:
            jj = jj and (len(np.where(a == i)[0]) == 1)
        else:
            jj = jj and (len(np.where(a == i)[0]) == 2)
if jj:
    print (2 ** (n / 2)) % (10 ** 9 + 7)
else:
    print 0

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
A = list(map(int,raw_input().split()))
MOD = 10**9 + 7
def calc(a):
	if 0 in a:
		if a.count(0) != 1:
			return 0
		a.remove(0)
		b = [a.count(i*2) for i in range(1,int(N/2) + 1)]
		if b.count(2) != int(N/2):
			return 0
	else:
		b = [a.count(i*2-1) for i in range(1,int(N/2) + 1)]
		if b.count(2) != int(N/2):
			return 0

	return 2 ** int(N/2)

print(calc(A) % MOD)