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:
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7
x=dict()
y=dict()
flag=True

if N%2==0:
    for i in range(1,N,2):
        x[i]=0
    for i in range(N):
        if A[i] in x:
            x[A[i]]+=1
        else:
            y[A[i]]=1
    for idx in x:
        if idx==0:
            if x[idx]<1:
                flag=False
            continue
        if x[idx]!=2:
            flag=False
    ans=1
    if flag:
        for idx in x:
            ans=ans*x[idx]
    else:
        print(0)
        exit()
    print(ans)

else:
    for i in range(0,N,2):
        x[i]=0
    for i in range(N):
        if A[i] in x:
            x[A[i]]+=1
        else:
            y[A[i]]=1
    for idx in x:
        if idx ==0:
            if x[idx]<1:
                flag=False
            continue
        if x[idx]!=2:
            flag=False
    ans=1
    if flag:
        for idx in x:
            ans=ans*x[idx]
    else:
        print(0)
        exit()
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
flg = True
if n%2==0:
  if 0 in a or len(set(a))!=n//2:
    flg=False
else:
  if len([0 for i in a if a==0])!=1 or len(set(a))!=n//2+1:
    flg=False
if flg:
  print(2**(n//2)%(10**9+7))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
if N%2==1:
    collect=list(range(0,N))[::2]*2
    collect.remove(0)
elif N % 2 == 0:
    collect = list(range(1, N))[::2] * 2

collect.sort()
if collect!=A:
    print(0)
else:
    print(2**(N//2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
n = N-1
for i in range(N//2):
  if A[2*i]!=n or A[2*i+1]!=n:
    print(0)
    exit()
  n -= 2
  
if N&1 and A[-1]!=0:
  print(0)
  exit()

print(1<<N//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
n = N-1
for i in range(N//2):
  if A[2*i]!=n or A[2*i+1]!=n:
    print(0)
    exit()
  n -= 2
  
if N&1 and A[-1]!=1:
  print(0)
  exit()

print(1<<N//2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)
if N%2==1:
  D=[0]
  for i in range(N-1):
    D.append((i//2)*2+2)
  if B==D:
    print(2**((N-1)//2)) 
  else:
    print(0)
else:
  D=[(i//2)*2+1 for i in range(N)]
  if B==D:
    print(2**(N//2))
  else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

e = [n]*n
for i in range(n):
  e[i] = abs((n - i) - (i+1))
  
A = map(int, input().split())

import collections
ac = collections.Counter(A)
ec = collections.Counter(e)
if ac != ec:
  print(0)
  exit()

a = list(ac.elements()) 
if n % 2 == 0:
  al = len(set(a))
  print(al**2)
else:
  al = len(set(a)) - 1
  print(al**2)

Submission status: Wrong Answer

Solution code:
n,l=int(input()),list(input().split())
if n%2==0:
  f=all(l.count(l[i])==2 for i in range(n))
else:
  f=all(l.count(l[i])==2 for i in range(n) if l[i]!=0) and l.count(0)==1 
print(2**(n//2)%1000000007 if f==True else 0)

Submission status: Wrong Answer

Solution code:
n,l=int(input()),list(input())
if n%2==0:
  f=all(l.count(l[i])==2 for i in range(n))
else:
  f=all(l.count(l[i])==2 for i in range(n) if l[i]!=0) and l.count(0)==1 
print(2**(n//2)%1000000007 if f==True else 0)

Submission status: Wrong Answer

Solution code:
n,l=int(input()),list(input())
f=any(l.count(l[i])!=2 and l.count(0)==1 for i in range(n))
print(2**(n//2)%1000000007 if f is True else 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
if n % 2 == 1:
    if a == odd:
        print(pow(2,n-1 // 2,10**9+7))
    else:
        print(0)
else:
    if a == even:
        print(pow(2,n // 2,10**9+7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
if n % 2 == 1:
    if a == odd:
        print(2 ** (n-1 // 2))
    else:
        print(0)
else:
    if a == even:
        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.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
print(n // 2)
if n % 2 == 1:
    if a == odd:
        print(2 ** (n-1 // 2))
    else:
        print(0)
else:
    if a == even:
        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.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
print(even)
print(odd)
print(n // 2)
if n % 2 == 1:
    if a == odd:
        print(2 ** (n-1 // 2))
    else:
        print(0)
else:
    if a == even:
        print(2 ** (n // 2))
    else:
        print(0)

Submission status: Wrong Answer

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

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        length = len(d)
        times = length if length % 2 == 0 else length - 1
        ans = 2
        for _ in range(times - 1):
            ans *= 2
            ans %= 1000000007
    else:
        ans = 0   
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    d = {}
    for a in A:
        if a not in d:
            d[a] = 0
        d[a] += 1
    ks =  all(map(lambda k: k % 2 == 0, d.keys())) or all(map(lambda k: k % 2 != 0, d.keys()))
    if 0 in d:
        d[0] += 1
    vs = all(map(lambda v: v == 2, d.values()))

    if ks and vs:
        times = int(N / 2) if len(d) % 2 == 0 else int((N - 1) / 2)
        ans = 1
        for _ in range(times):
            ans *= 2
            ans %= 1000000007
    else:
        ans = 0   
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
*a, = map(int, input().split())
a.sort()
ok = True
t = 1
if N % 2 == 1:
    if a.pop(0) != 0:
        ok = False
    t = 2

if ok:
    for i in range(0, len(a), 2):
        if t != a[i] or t != a[i+1]:
            ok = False
            break
        t += 2

if ok:
    print(2**((N-N % 2)//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
base = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

counter = [0 for i in range(N)]
flag = True
for i in range(N):
  counter[i] += 1
  
for i in range(N):
  if counter[i] > 2:
    flag = False
if counter[0] > 1:
  flag = False
  
if flag:
  if N % 2 == 0:
    print(2**(N//2) % base)
  else:
    print(2**((N-1)//2) % base)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A.sort()
if n % 2 == 0:
  if A[::2] == A[1::2] == [i for i in range(1, n + 1, 2)]:
    ans = 2 ** (n // 2)
  else:
    ans = 0
else:
  if A == [0] or A[1::2] == A[2::2] == [i for i in range(2, n + 1, 2)]:
    ans = 2 ** (n // 2)
  else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import Counter
INF = float("inf")

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    c = Counter(A)
    flag = True
    if N % 2 == 0:
        for i in range(1, N, 2):
            if c[i] != 2:
                flag = False
        if flag == False:
            print(0)
            return
    else:
        for i in range(0, N, 2):
            if i == 0:
                if c[i] != 1:
                    flag = False
            elif c[i] != 2:
                flag = False
        if flag == False:
            print(0)
            return
    print(2**(N//2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_set = set(a)
if n%2==0:
  if n//2 != len(a_set) or 0 in a_set:
    print(0)
  else:
    print(2**len(a_set)%(10**9+7))
else:
  if n//2+1 != len(a_set) or not 0 in a_set:
    print(0)
  else:
    print(2**(len(a_set)-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_set = set(a)
if n%2==0:
  if n//2 != len(a_set) or 0 in a_set:
    print(0)
  else:
    print(2**len(a_set)%(10**9+7))
else:
  if n//2+1 != len(a_set):
    print(0)
  else:
    print(2**(len(a_set)-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_set = set(a)
if n%2==0:
  if n//2 != len(a_set) or 0 in a_set:
    print(0)
  else:
    print(2**len(a_set))
else:
  if n//2+1 != len(a_set):
    print(0)
  else:
    print(2**(len(a_set)-1))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a_set = set(a)
if n%2==0:
  if n//2 != len(a_set):
    print(0)
  else:
    print(2**len(a_set))
else:
  if n//2+1 != len(a_set):
    print(0)
  else:
    print(2**(len(a_set)-1))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

numbers = Counter(list(range(not N % 2, N, 2)) * 2)
if N % 2:
    numbers[0] = 1
if Counter(A) == numbers:
    print(pow(2, (N // 2), int(10e9 + 7)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

numbers = Counter(list(range(not N % 2, N, 2)) * 2)
if N % 2:
    numbers[0] = 1
if Counter(A) == numbers:
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

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

if n % 2 != 0:
  if aList[0] != 0 and aList[1] == 0:
    print(0)
    exit(0)
  else:
    aList.pop(0)

for i in range(0,n-1,2):
  if i == 0:
    if aList[i] != aList[i+1]:
      print(0)
      exit(0)
  else:
    if aList[i] != aList[i+1] and aList[i] == aList[i-1]:
      print(0)
      exit(0)

result = 2
for i in range(1,n//2):
  result = (2*result)%  (10**9+7)

print(int(result))

Submission status: Wrong Answer

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

A_dict = dict()
if N % 2 == 0:
    for i in range(1, N, 2):
        A_dict[i] = 0
else:
    for i in range(0, N, 2):
        A_dict[i] = 0

for a in A:
    if a not in A_dict:
        print(0)
        exit()
    else:
        A_dict[a] += 1

for k, v in A_dict.items():
    if k == 0:
        if v != 1:
            print(0)
            exit()
    else:
        if v != 2:
            print(0)
            exit()
            
print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
n=int(input())
from collections import Counter
m=10**9+7
a=list(map(int,input().split()))
l=n//2

if n == 1:
  if a==[0]:
    print(1)
  else:
    print(0)
  exit()

if n%2==1:
  k=(n+1)//2
  ideal = [(2*i-2,2) for i in range(2,k+1)]+[(0,1)]
  A=Counter(a).most_common()
  if ideal != A:
    print(0)
    exit()
else:
  k=n//2
  ideal=[(2*i-1,2) for i in range(1,k+1)]
  A=Counter(a).most_common()
  if ideal!=A:
    print(0)
    exit()
ans=1
for i in range(l):
  ans*=2
  if ans >= m:
    ans %= m
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
m=10**9+7
l=n//2
ans=1
for i in range(l):
  ans*=2
  if ans >= m:
    ans %= m
print(ans)

Submission status: Wrong Answer

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

from collections import Counter

ctr = Counter(A)

if N % 2 and ctr[0] != 1:
    print(0)
    exit()

if N % 2 == 0:
    for i in range(2, N ,2):
        if ctr[i] != 2:
            print(0)
            exit()
else:
    for i in range(1, N, 2):
        if ctr[i] != 2:
            print(0)
            exit()

MOD = 10 ** 9 + 7
ans = 2 ** (N//2) % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = 0
for i in set(a):
  if n%2 == 1:
    if i == 0 and a.count(i) == 1:
      pass
    elif i%2 == 0 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()
  else:
    if i%2 == 1 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()

ans = 2
for i in range(n//2-1):
  ans = ans*2%m
print(ans)

Submission status: Wrong Answer

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

if len([v for k,v in c.items() if k > 0 and v != 2]):
    print(0)
    exit()
if n % 2 == 1 and c.get(0,0) != 1:
    print(0)
    exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = sorted(list(map(int,input().split())))
Ac = Counter(A)
if N%2 == 1:
    if A == [0]+sorted([2*i for i in range(1,N//2+1)]*2):
        flag = True
    else:
        flag = False
else:
    if A == sorted([1+2*i for i in range(N//2)]*2):
        flag = True
    else:
        flag = False
if flag:
    print(2**(N//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = int(1e+9 + 7)
p = 0
D = {N-1-2*i: 0 for i in range((N+1)//2)}
for i in A:
  if i in D:
    D[i] += 1
s = 0
if sum(D[i] for i in D) == N and max(D[i] for i in D) == 2:
  if 0 in D:
    if D[0] == 1:
      s = 1
  else:
    s = 1
if s == 1:
  p = 1
  for i in range(N//2):
    p *= 2
    p %= mod
print(p)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
*a, = map(int, input().split())

c = collections.Counter(a)
for k, v in c.items():
    if n%2 == 0:
        if v != 2:
            print(0)
            quit()
    else:
        if k != 0 and v != 2 or k == 0 and v != 1:
            print(0)
            quit()

print(2**(n//2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
k=(n+1)//2
b=[0]*(k)
for i in range(n):
  b[a[i]//2]+=1
out=1
if k%2==0:
  for i in range(k):
    if b[i]==2:
      out*=2
    else:
      out*=0
else:
  for i in range(1, k):
    if b[i]==2:
      out*=2
    else:
      out=0
  if b[0]!=1:
    out=0
print(out%(10**9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
waru = 10**9+7
N = int(input())
S = list(map(int,input().split()))
if(N%2==0):
	if not(S.count(0) == 1):
		ans = 0
		print(0)
		exit()
	for i in range(N//2):
		for i in range(N//2):
			if not(S.count(i*2+1) == 2):
				ans = 0
				break
	ans = 2**(N//2)%waru
else:
	if not(S.count(0) == 1):
		ans = 0
		print(0)
		exit()
	for i in range(N//2):
		if not(S.count(i*2) == 2):
			ans = 0
			break
	ans = 2**(N//2)%waru
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = list(map(int,input().split()))
if(N%2==0):
	for i in range(N//2):
		for i in range(N//2):
			if not(S.count(i*2+1) == 2):
				ans = 0
				break
	ans = 2**(N//2)
else:
	if not(S.count(0) == 1):
		ans = 0
		print(0)
		exit()
	for i in range(N//2):
		if not(S.count(i*2) == 2):
			ans = 0
			break
	ans = 2**(N//2)
print(ans)

Submission status: Wrong Answer

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

A.sort(reverse=True)
ans = 2 ** (N//2)
for i in range(N-1):
    if (i%2 != 0):
        continue
    else:
        print(A[i],A[i+1])
        if(A[i] != N-(i+1) or A[i+1] != N-(i+1)):
            ans = 0

if (N%2 != 0 and A[-1] != 0):
    ans = 0

print(ans%(10**9+7))

Submission status: Wrong Answer

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

A.sort(reverse=True)
ans = (N//2) ** 2
for i in range(N-1):
    if (i%2 != 0):
        continue
    else:
        if(A[i] != N-(i+1) or A[i+1] != N-(i+1)):
            ans = 0

if (N%2 != 0 and A[-1] != 0):
    ans = 0

print(ans%(10**9+7))

Submission status: Wrong Answer

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

A.sort(reverse=True)
ans = (N//2) ** 2
for i in range(N-1):
    if (i%2 != 0):
        continue
    else:
        if(A[i] != N-(i+1) or A[i+1] != N-(i+1)):
            ans = 0

if (N%2 != 0 and A[-1] != 0):
    ans = 0

print(ans)

Submission status: Wrong Answer

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

from collections import defaultdict
dic = defaultdict(int)
if n % 2 == 0:
   for a in al:
      dic[a] += 1
   for i in range(n//2):
      if dic[i*2+1] == 2:
         pass
      else:
         break
   else:
      print(2**(n//2))
      import sys
      sys.exit()
   print(0)
   import sys
   sys.exit()
else:
   for a in al:
      dic[a] += 1
   for i in range(n//2):
      if i == 0:
         if dic[i] == 1:
            pass
         else:
            break
      else:
         if dic[i*2] == 2:
            pass
         else:
            break
   else:
      print(2**(n//2))
      import sys
      sys.exit()
   print(0)
   import sys
   sys.exit()

Submission status: Wrong Answer

Solution code:
def even_case(input_list) -> int:
    input_list.sort()

    if input_list[0] == 0: return 0


    for i in range(1, len(input_list), 2):
        if input_list[i] // 2 == 1 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** (n//2)

    return ans


def odd_case(input_list) -> int:
    input_list.sort()

    if input_list[0] != 0: return 0

    if len(input_list) == 1: return 1

    if input_list[1] == 0: return 0

    for i in range(2, len(input_list), 2):
        if input_list[i] // 2 == 0 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** ((n-1) // 2)

    return ans

n = int(input())
input_list = list(map(int, input().split()))
math = 10 ** 9 + 7

if n % 2 == 0:
    result = even_case(input_list)
else:
    result = odd_case(input_list)

print(result % math)

Submission status: Wrong Answer

Solution code:
def even_case(input_list) -> int:
    input_list.sort()

    for i in range(1, len(input_list), 2):
        if input_list[i] // 2 == 1 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** (n//2)

    return ans


def odd_case(input_list) -> int:
    input_list.sort()

    if input_list[0] != 0: return 0

    if len(input_list) == 1: return 1

    if input_list[1] == 0: return 0

    for i in range(2, len(input_list), 2):
        if input_list[i] // 2 == 0 and input_list[i] != input_list[i-1]:
            return 0

    ans = 2 ** ((n-1) // 2)

    return ans

n = int(input())
input_list = list(map(int, input().split()))
math = 10 ** 9 + 7

if n % 2 == 0:
    result = even_case(input_list)
else:
    result = odd_case(input_list)

print(result % math)

Submission status: Wrong Answer

Solution code:
n=int(input())
numbb=input().split(' ')
numb=[]
for i in numbb:
    numb.append(int(i))
numb=sorted(numb)
#print(numb)
if(n==len(numb)):
    if(n%2!=0):
        temp=[]
        temp.append(0)
        strt=2
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(((pow(2,len(set(numb))-1)%(10**9)))+7)
        else:
            print(0)
    if(n%2==0):
        temp=[]
        strt=1
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            #print(pow(2,len(set(numb))))
            print(((pow(2,len(set(numb)))%(10**9)))+7)
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
numbb=input().split(' ')
numb=[]
for i in numbb:
    numb.append(int(i))
numb=sorted(numb)
#print(numb)
if(n==len(numb)):
    if(n%2!=0):
        temp=[]
        temp.append(0)
        strt=2
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(pow(2,len(set(numb))-1))
        else:
            print(0)
    if(n%2==0):
        temp=[]
        strt=1
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(pow(2,len(set(numb))))
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
numbb=input().split(' ')
numb=[]
for i in numbb:
    numb.append(int(i))
numb=sorted(numb)
#print(numb)
if(n==len(numb)):
    if(n%2!=0):
        temp=[]
        temp.append(0)
        strt=2
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(pow(2,len(set(numb))-1))
        else:
            print(0)
    if(n%2==0):
        temp=[]
        strt=1
        for i in range(0,int(n/2)):
            temp.append(strt)
            temp.append(strt)
            strt+=2
        if(temp==numb):
            #print(temp,numb)
            print(pow(2,len(set(numb))-1))
        else:
            print(0)

Submission status: Wrong Answer

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

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

from collections import Counter

cnt = min(A)
if cnt != N % 2:
    pass
else:
    print(0)
    exit()

for key,count in sorted(Counter(A).items(), key=lambda x:x[0]):
    if key != cnt:
        print(0)
        exit()
    cnt += 2
    if key == 0 and N % 2 == 1 and count == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

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

Submission status: Wrong Answer

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

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

from collections import Counter

cnt = min(A)
for key,count in sorted(Counter(A).items(), key=lambda x:x[0]):
    if key != cnt:
        print(0)
        exit()
    cnt += 2
    if key == 0 and N % 2 == 1 and count == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

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

Submission status: Wrong Answer

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

N = int(input())
A = sorted([int(i) for i in input().split()])

from collections import Counter

for key,count in Counter(A).items():
    if key == 0 and N % 2 == 1 and count == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

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

Submission status: Wrong Answer

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

N = int(input())
A = sorted([int(i) for i in input().split()])

from collections import Counter

for key,count in Counter(A).items():
    if key == 0 and N % 2 == 1 and count == 2:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

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

Submission status: Wrong Answer

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

N = int(input())
A = sorted([int(i) for i in input().split()])

from collections import Counter

for key,count in Counter(A).items():
    if key == 0 and N % 2 == 1:
        continue
    if count == 2 and key % 2 != N % 2:
        continue
    print(0)
    exit()

if N % 2 == 1:
    N -= 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
if N%2 == 0:
  check=[2*i+1 for i in range((N-1)//2+1)]*2
  check.sort()
else:
  check=[2*(i+1) for i in range(N//2)]*2
  check.append(0)
  check.sort()
if check == A:
  print(2**(N//2))
else:
  print(0)

Submission status: Wrong Answer

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

if len(L)%2 == 0 and len(set(L))*2 == len(L):
    print(2**len(set(L)))
elif len(L)%2 == 0 and len(set(L))*2 != len(L):
    print(0)
elif len(L)%2 == 1: 
    if L.count(0) == 1:
        L.pop(0)
        if len(set(L))*2 == len(L):
            print(2**(len(set(L))))
    else:
        print(0)

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)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)
    exit()
else:
    print(0)
    exit()
if len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print((len(c.values())**2)%mod)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print(((len(c.values())-1)**2)%mod)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

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)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print((len(c.values())%mod**2))
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print(((len(c.values())-1)%mod**2))
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

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)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print((len(c.values())**2)%mod)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print(((len(c.values())-1)**2)%mod)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

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)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print((len(c.values())%mod**2)%mod)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print(((len(c.values())-1)%mod**2)%mod)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

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)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print(len(c.values())**2%mod)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print((len(c.values())-1)**2%mod)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())

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

# 各数字の出現回数を調べる
c = collections.Counter(A)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==1 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print(len(c.values())**2)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print((len(c.values())-1)**2)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())

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

# 各数字の出現回数を調べる
c = collections.Counter(A)

# 可否判定
# 偶数ならすべての数字の出現回数が2である
# 奇数なら1つを除き、すべての数字の出現回数が2であり、1つの数字の出現回数が1である

if len(A) ==0 and A[0]==0:
    print(1)

elif len(A)%2==0:
    if list(c.values()).count(2) == (len(A) // 2 ):
        print(len(c.values())**2)
    else:
        print(0)
else:
    if list(c.values()).count(2) == (len(A) // 2 ) and c[0] == 1:
        print((len(c.values())-1)**2)
    else:
        print(0)
    



# 数字のペア数の2乗が組み合わせ数