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:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def check(L, n):
        # n 偶数 -> 1 1 3 3 5 5 ...
        if n % 2 == 0:
            for i in range(n):
                if (i % 2 == 0 and L[i] != i + 1) or (i % 2 == 1 and L[i] != i):
                    return False
        # n 奇数 -> 0 2 2 4 4 6..
        else:
            for i in range(n):
                if (i % 2 == 0 and L[i] != i) or (i % 2 == 1 and L[i] != i + 1):
                    return False
        return True

    
    n = ii()
    L = lmi()
    L.sort()
    if check(L, n):
        if n % 2 == 1:
            print(pow(2, (n - 1)//2))
        else:
            print(pow(2, n//2))
    else:
        print(0)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
ans=1
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from collections import Counter

d=Counter(a)
if d[0]==0:
    print(0)
    

for i , j in d.items():
    if n%2 == 0 and i ==0:
        print(0)
        exit()
    if i == 0  and j>1 :
        print(0)
        exit()
    if j!=2 and not(i==0):
        print(0)
        exit()
    if not(i==0):
        ans*=2
        ans%=mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
ans=1
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
from collections import Counter
d=Counter(a)
for i , j in d.items():
    if n%2 == 0 and i ==0:
        print(0)
        exit()
    if i == 0  and j>1 :
        print(0)
        exit()
    if j!=2 and not(i==0):
        print(0)
        exit()
    if not(i==0):
        ans*=2
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
di = collections.Counter(A)
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if di[num] != 2:
            break
    else:
        if A.count(0) == 1:
            ans = (2 ** (N // 2)) % (10 ** 7 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for i in num_list:
        if di[i] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 7 + 7)



print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
di = collections.Counter(A)
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if di[num] != 2:
            break
    else:
        if A.count(0) == 0:
            ans = (2 ** (N // 2)) % (10 ** 7 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for i in num_list:
        if di[i] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 7 + 7)



print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
di = collections.Counter(A)
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if di[num] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 7 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for i in num_list:
        if di[i] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 7 + 7)



print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        if A.count(0) == 1:
            for j in range(N // 2):
                ans = ans * 2 % (10**9 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for num in num_list:
        if A.count(num) != 2:
            break
    else:
        for j in range(N // 2):
            ans = ans * 2 % (10 ** 9 + 7)

print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
c = collections.Counter(a)
cl = ""
if n%2 == 1:
	cl = "odd"
else:
	cl = "even"
ans = 0
if cl == "odd":
	for i in c:
		if i%2 == 1:
			print (ans)
			exit()
		if i == 0:
			if c[i] != 1:
				print (ans)
				exit()
		else:
			if c[i] != 2:
				print (ans)
				exit()
	ans = 2**(n//2)%mod
else:
	for i in c:
		if i%2 == 2:
			print (ans)
			exit()
		if c[i] != 2:
			print (ans)
	ans = 2**(n//2)%mod
print (ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = set(l)

if sum(l) == 2 * sum(s):
  flg = True
else:
  flg = False
#print(c)
print((n//2)**2%(10**9+7) if flg else 0)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = set(l)

if sum(l) == 2 * sum(s):
  flg = True
else:
  flg = False
#print(c)
print((n//2)**2%1000000007 if flg else 0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
l = list(input().split())
flg = True
c = collections.Counter(l)
if n%2 == 0:
  flg = all(i == 2 for i in c.values())
else:
  g = c.pop("0") == 1
  flg = all(i == 2 for i in c.values()) and g
#print(c)
print((n//2)**2%1000000007 if flg else 0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
l = list(input().split())
flg = True
c = collections.Counter(l)
if n%2 == 0:
  flg = all(i == 2 for i in c.values())
else:
  g = c.pop("0") == 1
  flg = all(i == 2 for i in c.values()) and g
#print(c)
print((n//2)**2%1000000007 if flg else 0)

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    c = Counter(a)
    if n % 2 == 0:
        f = all(x == 2 for x in c.values())
    else:
        g = c.get(0) == 1
        f = all(x == 2 for x in c.values()) and g
    ans = 2 ** (n // 2) % 1000000007 if f is True else 0
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if N%2 == 0:
  B = list(range(N-1,0,-2))+list(range(1,N,2))
else:
  B = list(range(N-1,0,-2))+list(range(0,N,2))

if Counter(A) != Counter(B):
  print(0)
else:
  print(2**(N//2))

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
d = {}

for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
        continue
    d[A[i]] = 1

d = sorted(d.items(), key=lambda x:x[0])
ans = 1

if N%2==0:
    for key,data in d:
        if data==2:
            ans = data*ans
else:
    for key,data in d:
        if key==0:
            if data>1:
                print(0)
                exit()
            elif data==1:
                continue
            else:
                print(0)
                exit()
        if data==2:
            ans = data*ans  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
d = {}

for i in range(N):
    if A[i] in d:
        d[A[i]] += 1
        continue
    d[A[i]] = 1

d = sorted(d.items(), key=lambda x:x[0])
ans = 1

if N%2==0:
    for key,data in d:
        if data%2==0:
            ans = data*ans
else:
    for key,data in d:
        if key==0:
            if data>1:
                print(0)
                exit()
            elif data==1:
                continue
            else:
                print(0)
                exit()
        if data%2==0:
            ans = data*ans  
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans)
else:
    c = collections.Counter(a)
    value = []
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    if item[0][0] == 0 and item[0][1] == 1:
        print(ans)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

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

if n%2 == 0:
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    ans = 1
    for i in range(len(item)):
        if 2*i + 1 == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans)
else:
    c = collections.Counter(a)
    value = []
    ans = 1
    item = []
    for key,value in c.items():
        item.append([key,value])
    item.sort()
    for i in range(1,len(item)):
        if 2*i == item[i][0]:
            if item[i][1] == 2:
                ans *= 2
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
a.sort()
d = []
if n%2 == 1:
    for i in range(n//2):
        d.append(2*i+2)
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    ans = 1
    flag = False
    for i in range(1,len(item)):
        if item[i][0] == d[i-1] and item[i][1] == 2:
            flag = True
            ans *= 2
        else:
            flag = False
            break
    if flag == True and item[0][0] == 0 and item[0][1] == 1:
        print(ans)
    else:
        print(0)

else:
    for i in range(n//2):
        d.append(2*i+1)
    c = collections.Counter(a)
    item = []
    for key,value in c.items():
        item.append([key,value])
    ans = 1
    flag = False
    for i in range(len(item)):
        if item[i][0] == d[i] and item[i][1] == 2:
            flag = True
            ans *= 2
        else:
            flag = False
            break
    if flag == True:
        print(ans)
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[1]==1 and A[i]-2==A[i-2] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-2] and A[-1]==N-1 for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[1]==1 and A[i]-2==A[i-2] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-2] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-2] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i-1] and A[i]-2==A[i-1] for i in range(2,N,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i+1] and A[i+1]+2==A[i+2] for i in range(1,N-2,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i+1]==A[i+2] and A[i+1]+2==A[i+3] for i in range(0,N-3,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

A=sorted(A)

if N%2==0:
    if all(A[i]==A[i+1] and A[0]==1 and A[i]+2==A[i+2] for i in range(0,N-2,2)):
        print(2**(N//2))
    else:
        print(0)
else:
    if all(A[0]==0 and A[i]==A[i+1] and A[i]+2==A[i+2] for i in range(1,N-2,2)):
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
mod = 10**9 + 7
c = Counter(A)
flg = True
for k,v in c.items():
    if k==0 and v!=1:
        flg = False
    elif v!=2:
        flg = False
if flg is False:
    print(0)
else:
    print(pow(2, n//2, mod))

Submission status: Wrong Answer

Solution code:
import collections
def solve(n, a_list):

    count = collections.Counter()
    for a in a_list:
        count[a] += 1

    count[0] += 1
    c = [False] * n
    for k, v in count.items():
        c[k] = (v == 2)

    if n % 2 == 1:
        tmp = all([v for i, v in enumerate(c) if i % 2 == 0])
    else:
        tmp = all([v for i, v in enumerate(c) if i % 2 == 1])

    if tmp:
        return 2 ** (n//2)
    else:
        return 0

if __name__ == "__main__":
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print(solve(n, a_list))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
counter = Counter(lst)

if N % 2 == 0:
    for x in range(1, N, 2):
        if counter[x] != 2:
            print(0)
            exit()

else:
    if counter[0] != 1:
        print(0)
        exit()
    for x in range(2, N + 1, 2):
        if counter[x] != 2:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
lst = [int(x) for x in input().split()]
counter = Counter(lst)

if N % 2 == 0:
    if len(counter) * 2 != N:
        print(0)
        exit()
    for x in range(1, N, 2):
        if counter[x] != 2:
            print(0)
            exit()

else:
    if len(counter) * 2 - 1 != N:
        print(0)
        exit()
    if counter[0] != 1:
        print(0)
        exit()
    for x in range(2, N + 1, 2):
        if counter[x] != 2:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    # A = readline().rstrip().split()
    A = list(input().replace(" ", ""))
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    # A = readline().rstrip().split()
    A = "".join(input().split())
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline

def resolve():
    N = int(input())
    # A = input().replace(" ", "")
    A = list(map(int, readline().rstrip().split()))
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 1:
        if counter["0"] != 1:
            print("0")
            return
        for k, v in counter.items():
            if k == "0":
                continue
            if int(k) % 2 == 1:
                print("0")
                return
            if v != 2:
                print("0")
                return
    else:
        for k, v in counter.items():
            if int(k) % 2 == 0:
                print("0")
                return
            if v != 2:
                print("0")
                return
    
    print( (2**(N//2)) % (10**9+7) )




if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    #print(counter)
    if N % 2 == 0:
        if list(map(str, range(1, N+1, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N+1, 2):
            i = str(i)
            if counter[i] > 2:
                print("0")
                return
        # for i in range(N):
        #     if i % 2 == 0:
        #         if str(i) in counter:
        #             print("0")
        #             return
        #         else:
        #             continue
        #     i = str(i)
        #     if counter[i] != 2:
        #         print("0")
        #         return
    else:
        # for i in range(N):
        #     if i % 2 == 1:
        #         if str(i) in counter:
        #             print("0")
        #             return
        #         else:
        #             continue
        #     i = str(i)
        #     if i == "0":
        #         if counter[i] != 1:
        #             print("0")
        #             return
        #     else:
        #          if counter[i] != 2:
        #             print("0")
        #             return
        if list(map(str, range(0, N+1, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N+1, 2):
            i = str(i)
            if i == "0":
                if counter[i] != 1:
                    print("0")
                    return
            else:
                if counter[i] > 2:
                    print("0")
                    return
    ans = 1
    for i in range(N//2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    #print(counter)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if counter[i] > 2:
                print("0")
                return
        # for i in range(N):
        #     if i % 2 == 0:
        #         if str(i) in counter:
        #             print("0")
        #             return
        #         else:
        #             continue
        #     i = str(i)
        #     if counter[i] != 2:
        #         print("0")
        #         return
    else:
        # for i in range(N):
        #     if i % 2 == 1:
        #         if str(i) in counter:
        #             print("0")
        #             return
        #         else:
        #             continue
        #     i = str(i)
        #     if i == "0":
        #         if counter[i] != 1:
        #             print("0")
        #             return
        #     else:
        #          if counter[i] != 2:
        #             print("0")
        #             return
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if counter[i] != 1:
                    print("0")
                    return
            else:
                if counter[i] > 2:
                    print("0")
                    return
    ans = 1
    for i in range(N//2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    #print(counter)
    if N % 2 == 0:
        # if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(1, N, 2):
        #     i = str(i)
        #     if counter[i] != 2:
        #         print("0")
        #         return
        for i in range(N):
            if i % 2 == 0:
                if str(i) in counter:
                    print("0")
                    return
                else:
                    continue
            i = str(i)
            if counter[i] != 2:
                print("0")
                return
    else:
        for i in range(N):
            if i % 2 == 1:
                if str(i) in counter:
                    print("0")
                    return
                else:
                    continue
            i = str(i)
            if i == "0":
                if counter[i] != 1:
                    print("0")
                    return
            else:
                 if counter[i] != 2:
                    print("0")
                    return
        # if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(0, N, 2):
        #     i = str(i)
        #     if i == "0":
        #         if counter[i] != 1:
        #             print("0")
        #             return
        #     else:
        #         if counter[i] != 2:
        #             print("0")
        #             return
    ans = 1
    for i in range((N+1)//2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)



if '__main__' == __name__:
    resolve()