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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr0=limii()

arr=Counter(arr0)

ai=list(arr.items())
ai.sort()
if n%2==0:
    cnt=0
    for p,i in enumerate(range(1,n,2)):

        if ai[p][0]==i and ai[p][1]==2:
            cnt+=1
    if cnt==n//2:
        print(2**(n//2))
else:
    cnt=0
    for p,i in enumerate(range(0,n,2)):
        if p==0:
            if ai[p][0]==i and ai[p][1]==1:
                cnt+=1
        else:        
            if ai[p][0]==i and ai[p][1]==2:
                cnt+=1
    if (n+1)//2==cnt:
        print(2**(cnt-1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
mod = 10**9 + 7
A = list(map(int, input().split()))
A.sort()
flag = True
if N % 2 == 1:
    if A[0] != 0:
        print(0)
        exit()
    else:
        for i in range(1, N, 2):
            if A[i] != A[i+1] or A[i] % 2 == 1:
                flag = False
else:
    for i in range(N, 2):
        if A[i] != A[i+1] or A[i] % 2 == 0:
            flag = False
ans = 1
if flag:
    for i in range(N//2):
        ans *= 2
        ans %= mod
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from numpy import *
n, *a = map(int, sys.stdin.read().split())
a = int_(bincount(a, [1] * n, n))
print(pow(2, n // 2, 10 ** 9 + 7) if not a[0] > (n & 1) and all(x == 2 for x in a[1:]) else 0)

Submission status: Wrong Answer

Solution code:
import sys
from numpy import *
n, *a = map(int, sys.stdin.read().split())
a = int_(bincount(a, [1] * n, n))
if not a[0] > 1 and all(x == 2 for x in a[1:]):
    print(pow(2, n // 2, 10 ** 9 + 7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

dic1 = dict()
oe = 1
if n%2 == 1:
    oe = 0
for i in range(oe,n,2):
    dic1[i] = 0

for i in lst1:
    if i in dic1:
        dic1[i] += 1
    else:
        print(0)
        exit()

if oe == 0:
    if dic1[0] != 1:
        print(0)
        exit()

ans = 1
for i in dic1.values():
    ans *= i
    if i > 2:
        ans *= 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

if N % 2 == 1:
  B = [0] * N
  for i in range(1,N):
    b = math.ceil(i / 2) * 2
    B[i] = b
else:
  B = [0] * N
  for i in range(N):
    b = math.floor(i / 2) * 2 + 1
    B[i] = b

if A == B:
  if N % 2 == 1:
    n = (N - 1) // 2
  else:
    n = N // 2
  print(2 ** n)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
A=list(map(int,input().split()))
A=collections.Counter(A)
for i in range(1,N,2) if N%2==0 else range(2,N,2):
    if A[i]!=2:
        print(0)
        exit()
if N%2==1:
    if not 0 in A or A[0]!=1:
        print(0)
        exit()
print(2**((N-N%2)//2))

Submission status: Wrong Answer

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

if N % 2 == 0:
    A_list = []
    for i in range(1, N, 2):
        A_list.extend([i, i])
else:
    A_list = [0]
    for i in range(2, N, 2):
        A_list.extend([i, i])
if A != A_list:
    print(0)
else:
    print(2**(N//2))

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
A = sorted(A)
if N & 1 != 0:
  K = 2
  F = True
  for i in range(1, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  if A[0] != 0:
    F = False
  print(2 ** (N // 2) if F else 0)
else:
  K = 1
  F = True
  for i in range(0, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  print(2 ** (N // 2) if F else 0)

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())
A = sorted(A)
if N & 1 != 0:
  K = 2
  F = True
  for i in range(1, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  if A[0] != 0:
    F = False
  print((N // 2) ** 2 if F else 0)
else:
  K = 1
  F = True
  for i in range(0, N, 2):
    if A[i] != A[i+1] or A[i] != K:
      F = False
      break
    K += 2
  print((N // 2) ** 2 if F else 0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
dd = collections.defaultdict(int)
correct = []
if n % 2 == 1:
    correct.append(0)
    for i in range((n - 1) // 2):
        correct.append(2 * i + 2)
        correct.append(2 * i + 2)
else:
    correct.append(1)
    correct.append(1)
    for i in range(n // 2):
        correct.append(2 * i + 3)
        correct.append(2 * i + 3)
a.sort()
correct.sort()
for i in range(n):
    if a[i] != correct[i]:
        print(0)
        exit()
for i in range(n):
    dd[str(a[i])] += 1
ans = 1
for k in dd.keys():
    if dd[k] >= 2:
        ans *= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
ans = 2 ** (N//2)
for i in range(N//2 * 2):
    if (i + N%2)//2 * 2 + (N + 1)%2 != A[i]:
        ans = 0
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import collections

N=int(input())
A = np.array(list(map(int, input().split())))
if np.count_nonzero(A ==0)>=2:
    print("0")
else:
    dict=collections.Counter(A)
    key = [k for k, v in dict.items() if int(v) == 2]
    if len(key)==0:
        print("0")
    else:
        ans=2**len(key)
        ans =ans%(10**9+7)
        print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))
Count=sorted(Counter(A).items())
cnt=0
if n%2==1:
    if Count.pop(0)[1]==1 and len(Count)==n//2:
        point=2
        for v,m in Count:
            if v==point and m==2:
                cnt +=1
                point +=2
        print(2**cnt)
    else:print(0);exit()
else:
    point=1
    for v,m in Count:
        if v==point and m==2:
            cnt +=1
            point +=2
        else:print(0);exit()
    print(2**cnt)

Submission status: Wrong Answer

Solution code:
mod=10**9+7
n=int(input())
A=list(map(int,input().split()))
A.sort()
cnt=0
if n%2==1:
    point=2
    if A.pop(0)==0:
        for i in range(0,n-1,2):
            if A[i]==A[i+1]==point:
                cnt +=1
                point +=2
            else:print(0);exit()
        print(2**cnt)
    else:print(0);exit()
else:
    point=1
    for i in range(0,n,2):
        if A[i]==A[i+1]==point:
            cnt +=1
            point +=2
        else:print(0);exit()
    print(2**cnt)

Submission status: Wrong Answer

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

A.sort()
f=True
if N%2==1:
    if A[0]!=0:
        f=False
    else:
        for i in range(1,N,2):
            if not (A[i]==2*(i+1)//2 and A[i+1]==2*(i+1)//2):
                f=False
                break
elif N%2==0:
    for i in range(0,N,2):
        if not (A[i]==2*(i//2)+1 and  A[i+1]==2*(i//2)+1):
            f=False
            break

if f:
    print(2**(N//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
c = Counter(A)

if n % 2 == 1:
    # 誰かは真ん中にいる or 0は1人のみ
    if 0 not in c or c[0] != 1:
        print(0)
        exit()

# 偶数: 5, 3, 1, 1, 3, 5 -> 1, 3, 5をカウント (n//2)
# 奇数: 4, 2, 0, 2, 4 -> 2, 4をカウント (n//2)
for i in range(n // 2):
    x = i * 2 + (1 if n % 2 == 0 else 2)
    if x not in c or c[x] != 2:
        print(0)
        exit()

# (左から右) × 2(左右対称)
print(2 ** (n // 2))

Submission status: Wrong Answer

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

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)

Submission status: Wrong Answer

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

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 2
    print(ans**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 2
    print(ans**(N//2) % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 2
    # for i in range(N//2):
    #     ans *= 2 % mod
    print(ans**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 2
    # for i in range(N//2):
    #     ans *= 2 % mod
    print(ans**(N//2) % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    # for i in range(N//2):
    #     ans *= 2 % mod
    print(ans**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    # for i in range(N//2):
    #     ans *= 2 % mod
    print(ans**(N//2) % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(int(ans % mod))
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(int(ans % mod))

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
count = Counter(A)
now_key = 1
for k, v in count.items():
    if k != now_key or v != 2:
        print(0)
        exit()
    now_key += 2
ans = 1
for i in range(N//2):
    ans *= 2 % mod
print(ans % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    for i in range(int(N/2)):
        ans *= 2 % mod
    print(ans % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    for i in range(int(N/2)):
        ans *= 2 % mod
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
print(0)
exit()
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
# 答えは2**(N//2) % 1000000007
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    ans = 1
    for i in range(N//2):
        ans *= 2 % mod
    print(ans)

Submission status: Wrong Answer

Solution code:
n= input()
a=list(map(int,input().split()))
b=set()
b.update(a)
if(int(n)%2==0):
    q=len(b)
else:
    q=len(b)-1
if ( int(q)!= int(int(n)/2) or list(a).count(0) >1):
    print(0)
else:
    print(2**q)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_unique = list(set(a))
mod = 10 ** 9 + 7
if n % len(a_unique) != 0 and n % 2 == 0:
    print(0)
else:
    print(2 ** (n // 2) % mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
al=list(map(int,input().split()))
cl=Counter(al)
if n%2==0:
    for i in range(1,n,2):
        if cl[i]!=2:
            print(0)
            break
    else:
        print(2**(n//2))
else:
    if cl[0]!=1:
        print(0)
        exit()
    for i in range(2,n,2):
        if cl[i]!=2:
            print(0)
            break
    else:
        print(2**(n//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N=int(input())
C=Counter(list(map(int,input().split())))

f=True
if N%2==0:
    for i in range(1,N+1,2):
        if C[i]!=2:
            f=False
            ans=0
            break
    if f:
        ans=2**(N//2)
elif N%2==1:
    if C[0]!=1:
        f=False
        ans=0
    else:
        for i in range(2,N+1,2):
            if C[i]!=2:
                f=False
                ans=0
                break
    if f:
        ans=2**((N-1)//2)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N=int(input())
C=Counter(list(map(int,input().split())))

f=True
if N%2==0:
    if len(C.keys())!=N//2 or max(C.values())!=2 or min(C.values())!=2:
        ans=0
    else:
        ans=2**(N//2)
elif N%2==1:
    if len(C.keys())!=(N+1)//2 or max(C.values())!=2 or C[0]!=1:
        ans=0
    else:
        ans=2**((N-1)//2)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range((n+1)%2, n, 2):
  l += [i, i] if i>0 else [i]
a = sorted(list(map(int, input().split())))
if a == l:
  print(2 ** (n//2))
else:
  print(0)

Submission status: Wrong Answer

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

check = True
A = sorted(A)
print(A)
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i + 1:
            check = False
        if i % 2 == 1 and A[i] != i:
            check = False

if N % 2 != 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i:
            check = False
        if i % 2 == 1 and A[i] != i + 1:
            check = False

if check:
    print((2 ** (N // 2)) % (10 ** 9 + 7))
else:
    print(0)

Submission status: Wrong Answer

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

check = True
A = sorted(A)
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i + 1:
            check = False
        if i % 2 == 1 and A[i] != i:
            check = False

if N % 2 != 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i:
            check = False
        if i % 2 == 1 and A[i] != i + 1:
            check = False

if check:
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

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

check = []

if N % 2 == 1:
    for i in range(N // 2 + 1):
        if i == 0:
            check.append(i)
        else:
            check.append(i * 2)
            check.append(i * 2)

if N % 2 == 0:
    for i in range(N // 2):
        check.append(i * 2 + 1)
        check.append(i * 2 + 1)

if sorted(A) == check:
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=sorted(map(int,input().split()),reverse=True)

for i in range(N):
  if A[i]==N-2*(i//2)-1:
    pass
  else:
    print(0)
    exit()
    
print(2**(N//2))

Submission status: Wrong Answer

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

A.sort()
flag = True
for i in range(N):
  if N%2 == 0:
    if A[i] != (i//2)*2+1:
      flag = False
      break
  else:
    if A[i] != ((i+1)//2)*2:
      flag = False
      break
print(2**(N//2) if flag else 0)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
A.sort()


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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    # print(a)
    if(n % 2 == 0):
        for i in range(0, n-1):
            if i % 2 == 0 and a[i] != a[i+1] or i % 2 == 1 and a[i]+2 != a[i+1]:
                print(0)
                exit(0)
        print(2**(n//2))
        exit(0)
    for i in range(0, n-1):
        if(i == 0 and a[0]+2 != a[1]):
            print(0)
            exit(0)
        if i % 2 == 0 and a[i]+2 != a[i+1] or i % 2 == 1 and a[i] != a[i+1]:
            print(20)
            exit(0)
    print(2**(n//2))
    exit(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    if(n % 2 == 0):
        for i in range(1, n, 2):
            if(a[i-1:i+1].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[0:2].count(i) != 1):
            print(0)
            exit(0)
        elif(i != 0 and a[i-1:i+1].count(i) != 2):
            print(0)
            exit(0)
    print(2**(n//2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A.sort()

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

else:
    if(A[0]!=0):
            print(0)
            exit()
    for i in range(N//2):
        if((A[2*i+1]!=((i+1)*2))|(A[2*i+2]!=((i+1)*2))):
            print(0)
            exit()
    print(2**(N//2))

Submission status: Wrong Answer

Solution code:
def main():
  n=int(input())
  a=sorted(list(map(int,input().split())))
  if n%2==0:
    if a==[x//2*2+1 for x in range(n)]:
      print(2**(n//2))
      return
  else:
    if a==[0]+[x//2*2+2 for x in range(n-1)]:
      print(2**(n//2))
      return
  print(0)

main()

Submission status: Wrong Answer

Solution code:
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        ans=0
    else:
        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
        ans=2**((N-1)//2)
        ans=ans%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
    ans=2**(N//2)
    ans=ans%mod

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

#A=list(A_dict.items())

if N%2==1:
    if not A[0]==1:
        ans=0
    else:

        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
        ans=(2**((N-1)//2))%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
    ans=(2**(N//2))%mod

print(ans)

Submission status: Wrong Answer

Solution code:
import collections

N=int(input())
A_data=list(map(int,input().split()))
mod=10**9+7

A=collections.Counter(A_data)

if N%2==1:
    if not A[0]==1:
        ans=0
    else:

        for i in range(2,N,2):
            if not A[i]==2:
                ans=0
        ans=2**((N-1)//2)%mod
elif N%2==0:
    for i in range(1,N,2):
        if not A[i]==2:
            ans=0
    ans=2**(N//2)%mod

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
N = int(input())
A = [int(_) for _ in input().split()]

counter = Counter(A)

if N % 2 == 0:
    for n in range(1, N, 2):
        if counter[n] == 2:
            continue
        else:
            print(0)
            sys.exit()

elif N % 2 == 1:
    if counter[0] == 1:
        counter.pop(0)
        for n in range(2, N, 2):
            if counter[n] == 2:
                continue
            else:
                print(0)
                sys.exit()
    else:
        print(0)
        sys.exit()
ans = 2 ** (N // 2)
print(ans)