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

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

if N == 1:
	print(1)
	sys.exit()


t = []

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


if t == A:
	print((2**(N//2))%1000000007)
else:
	print(0)

#print(t)
#print(A)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	print(1)
	sys.exit()


t = []

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


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

#print(t)
#print(A)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	print(1)
	sys.exit()


t = []

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


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

#print(t)
#print(A)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	print(1)
	sys.exit()


t = []

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


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

print(t)
print(A)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	if A[0] == "0":
		print(1)
	else:
		print(0)
	sys.exit()


t = []

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


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

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	if A[0] == "0":
		print(1)
	else:
		print(0)
	sys.exit()


t = []

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


if t == A:
	print((2**(N//2))%1000000007)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	if A[0] == "0":
		print(1)
	else:
		print(0)
	sys.exit()


t = []

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


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

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	if A[0] == "0":
		print(1)
	else:
		print(0)
	sys.exit()


t = []

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


if "".join(t) == "".join(A):
	print(2**(N//2))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys

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

if N == 1:
	if A[0] == "0":
		print(1)
	else:
		print(0)
	sys.exit()


t = []

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

print(t)

if "".join(t) == "".join(A):
	print(2**(N//2))
else:
	print(0)

Submission status: Wrong Answer

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

t = []

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

if "".join(t) == "".join(A):
	print(2**(N//2))
else:
	print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A=[int(x) for x in input().split()]
H= True
A.sort()
if N%2==0:
  for i in range(N):
    if A[i] != 2*(i//2)+1:
      H=False
else:
  if A[0]!=0:
    H=False
  for i in range(1,N):
    if A[i]!=2*((i-1)//2)+2:
      H=False
print(2**(N//2) if H else '0')

Submission status: Wrong Answer

Solution code:
MOD=1000000007
N=int(input())
a=[int(_) for _ in input().split()]
cnt=[0]*N
if N%2==0:
    for i in range(N):
        cnt[a[i]]+=1
    f=True
    for i in range(N):
        if i%2==0 and cnt[i]!=0:
            f=False
        elif i%2==1 and cnt[i]!=2:
            f=False
    if f:
        res=1
        for i in range(N//2):
            res=(res*2)%MOD
        print(res)
    else:
        print(0)
elif N%2==1:
    for i in range(N):
        cnt[a[i]]+=1
    f=True
    for i in range(N):
        if i==0 and cnt[i]!=1:
            f=False
        elif i%2==0 and cnt[i]!=2:
            f=False
        elif i%2==1 and cnt[i]!=0:
            f=False
    if f:
        res=1
        for i in range((N-1)//2):
            res=(res*2)%MOD
        print(res)
    else:
        print(0)

Submission status: Wrong Answer

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

mod = 10**9 + 7

b = set(a)

if n%2==0:
    check = len([ i for i in a if i%2==1 ])
    print(check)
    if check==n and len(b)==(n//2):
        ans = 2**(n//2) % mod
        print(ans)
        exit()
    else:
        print(0)
        exit()
else:
    check = len([ i for i in a if i%2==0 ])
    if check==n and len(b)==((n+1)//2) and a.count(0)==1:
        ans = 2**((n-1)//2) % mod
        print(ans)
        exit()
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
INF = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
if n%2==0:
    p = [0]*(n//2)
    for i in range(n):
        x = (a[i]-1)//2
        p[x]+=1
    m = len(p)
    for i in range(m):
        if p[i]!=2:
            print(0)
            exit()
    ans = (2**m)%INF
else:
    p = [0]*(((n-1)//2)+1)
    for i in range(n):
        x = a[i]//2
        p[x]+=1
    m = len(p)
    if p[0]!=1:
        print(0)
        exit()
    for i in range(1,m):
        if p[i]!=2:
            print(0)
            exit()
    m -=1
    ans = (2**m)%INF

Submission status: Wrong Answer

Solution code:
INF = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
if n%2==0:
    p = [0]*(n//2)
    for i in range(n):
        x = (a[i]-1)//2
        p[x]+=1
    m = len(p)
    for i in range(m):
        if p[i]!=2:
            print(0)
            exit()
    print(2**m)
else:
    p = [0]*(((n-1)//2)+1)
    for i in range(n):
        x = a[i]//2
        p[x]+=1
    m = len(p)
    if p[0]!=1:
        print(0)
        exit()
    for i in range(1,m):
        if p[i]!=2:
            print(0)
            exit()
    m -=1
    print(2**m)

Submission status: Wrong Answer

Solution code:
INF = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
if n%2==0:
    p = [0]*(n//2)
    for i in range(n):
        x = (a[i]-1)//2
        p[x]+=1
    m = len(p)
    for i in range(m):
        if p[i]!=2:
            print(0)
            exit()
    print(2**m)
else:
    p = [0]*((n//2)+1)
    for i in range(n):
        x = a[i]//2
        p[x]+=1
    m = len(p)
    if p[0]!=1:
        print(0)
        exit()
    for i in range(1,m):
        if p[i]!=2:
            print(0)
            exit()
    m -=1
    print(2**m)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [int(i) for i in input().split()]
L.sort()

def out_detect(n,L):
  flag = 0
  if n%2 == 0:
    for i in range(n):
      if L[i] != -(-(i+1)//2)*2-1:
        flag = 1
        break
  else:
    if L[0] != 0:
      flag = 1
      return (flag)
    for i in range(1,n):
      if L[i] != (-(-i//2)*2):
        flag = 1
        break
  return (flag)

if out_detect(n,L) == 1:
  print(0)
else:
  if n%2 == 0:
    print(pow(2,n//2))
  else:
    print(pow(2,(n-1)//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
L = [int(i) for i in input().split()]
L.sort()
print(L)

def out_detect(n,L):
  flag = 0
  if n%2 == 0:
    for i in range(n):
      if L[i] != -(-(i+1)//2)*2-1:
        flag = 1
        break
  else:
    if L[0] != 0:
      flag = 1
      return (flag)
    for i in range(1,n):
      if L[i] != (-(-i//2)*2):
        flag = 1
        break
  return (flag)

if out_detect(n,L) == 1:
  print(0)
else:
  if n%2 == 0:
    print(pow(2,n//2))
  else:
    print(pow(2,(n-1)//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
set_A = set(A)

ans = 1

if n%2==0:
  if len(A)//2 != len(set(A)):
    ans = 0
else:
  if A.count(0)!=1:
    ans = 0
  
  set_A.remove(0)
  if len(A)//2 != len(set(A)):
    ans = 0
      
if ans!=0:
  ans = 2**(len(set_A))

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
n=N//2
MOD=10**9+7
ans=(n**2)%MOD

f=1
if N%2==1:
    for i in range(N):
        if A[i] != 2*(-(-i//2)):
            f=0
            break
else:
    for i in range(N):
        if A[i] != 1+(i//2)*2:
            f=0
            break

print([0,ans][f])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mod = 10 ** 7 + 1
N = int(input())
A = [int(a) for a in input().split()]
A.sort()

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

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

print(order_count)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 7 + 1
N = int(input())
A = [int(a) for a in input().split()]
A.sort()

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

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

print(order_count)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 7 + 1
N = int(input())
A = [int(a) for a in input().split()]
A.sort()

if N % 2 != 0:
    for i in range(0, N, 2):
        if A[i] != i:       
            print(0)
            exit()
    order_count = 2 ** ((N - 1) // 2) % mod

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

print(order_count)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
d={}
for i in range(n):
  d[i]=0
for i in l:
  d[i]+=1
b=True
if n%2==1:
  if d[0]!=1:
    b=False
  for i in range(1,n//2+1):
    if d[i*2]!=2:
      b=False
else:
  for i in range(n//2):
    if d[i*2+1]!=2:
      b=False
if b:
  print(2**(n//2))
else:
  print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C - Lining Up

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

if N%2 == 0:
    tmp = []
    tmp2 = 1
    while tmp2 <= N-1:
        tmp.extend([tmp2, tmp2])
        tmp2 += 2
        
    if A != tmp:
        print(0)
    else:
        print(2**(N//2))
    
else:
    tmp = [0]
    tmp2 = 2
    while tmp2 <= N-1:
        tmp.extend([tmp2, tmp2])
        tmp2 += 2
        
    if A != tmp:
        print(0)
    else:
        print(2**((N-1)//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
nums = {}
nums2 = {}
for i in range(1,n+1):
    left = i -1
    right = n -i
    a = abs(left - right)
    if a in nums:
        nums[a] +=1
    else:
        nums[a] = 1

for a in A:
    if a in nums2:
        nums2[a] +=1
    else:
        nums2[a] = 1
if nums==nums2:
    if n%2==1:
        print(2**(len(nums)-1))
    else:
        print(2**(len(nums)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
if N % 2 == 1:
  checklist = {0:1}
  for i in range((N-1)//2):
    checklist[(i+1)*2] = 2
else:
  checklist = {(i*2+1):2 for i in range(N//2)}

for a in A:
  if a in checklist and checklist[a] in {1,2}:
    checklist[a] -= 1
  else:
    print(0)
    exit()
print(int(2**(N//2)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
#並びが可能なら、2**(N//2)
#無理なら0
opt = {}
for i in range(N):
  a = abs((N-i-1)-i)
  if a not in opt :
    opt[a] = 1
  else :
    opt[a] += 1 
for i in range(N):
  if A[i] not in opt:
    print(0)
    exit()
  if opt[A[i]] == 0 :
    print(0)
    exit()
  opt[A[i]] -= 1 
print(2**(N//2))

Submission status: Wrong Answer

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

#並びが可能なら、2**(N//2)
#無理なら0
opt = {}
for i in range(N):
  a = abs((N-i-1)-i)
  if a not in opt :
    opt[a] = 1
  else :
    opt[a] += 1 
for i in range(N):
  if A[i] not in opt or opt[A[i]] == 0 :
    print(0)
    exit()
  else:
    opt[A[i]] -= 1 
print(2**(N//2))

Submission status: Wrong Answer

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

counter = collections.Counter(a)
ans = 1
for k, v in counter.items():
    if k != 0:
        if v == 2:
            ans *= 2
        if v == 1:
            ans = 0
            break
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]
    x = [0]*n
    if n % 2 == 0:
        for i in a:
            if i % 2 != 1:
                print(0)
                exit()
    else:
        for i in a:
            if i % 2 != 0:
                print(0)
                exit()
    for i in a:
        if i == 0 and x[i] == 1:
            print(0)
            exit()
        elif x[i] == 2:
            print(0)
            exit()
        else:
            x[i] += 1
    print(reduce(lambda x, y: x * y if y != 0 else x, x, 1) % 10 ** 9 + 7)

Submission status: Wrong Answer

Solution code:
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]
    x = [0]*n
    if n % 2 == 0:
        for i in a:
            if i % 2 != 1:
                print(0)
                exit()
    else:
        for i in a:
            if i % 2 != 0:
                print(0)
                exit()
    for i in a:
        if i == 0 and x[i] == 1:
            print(0)
            exit()
        elif x[i] == 2:
            print(0)
            exit()
        else:
            x[i] += 1
    print(reduce(lambda x, y: x * y if y != 0 else x, x, 1))

Submission status: Wrong Answer

Solution code:
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    a = [int(x) for x in input().split()]
    x = [0]*n
    for i in a:
        if i == 0 and x[i] == 1:
            print(0)
            exit()
        elif x[i] == 2:
            print(0)
            exit()
        else:
            x[i] += 1
    print(reduce(lambda x, y: x * y if y != 0 else x, x, 1))

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  a = na()
  mod = int(1e9+7)

  if n % 2 == 0:
    if 0 in a:
      print(0)
      return 
    else:
      print(2 ** len(list(set(a))) % mod)
  else:
    zero = 0
    for aa in a:
      if aa == 0:
        zero += 1
    if zero > 1:
      print(0)
      return
    else:
      x = len(list(set(a)))
      if zero == 1:
        print(2 ** (x - 1) % mod)
      else:
        print(2 ** x % mod)

main()

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  a = na()

  if n % 2 == 0:
    if 0 in a:
      print(0)
      return 
    else:
      print(2 ** len(list(set(a))))
  else:
    zero = 0
    for aa in a:
      if aa == 0:
        zero += 1
    if zero > 1:
      print(0)
      return
    else:
      x = len(list(set(a)))
      if zero == 1:
        print(2 ** (x - 1))
      else:
        print(2 ** x)

main()

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split()))
x = N//2

C = [0]*N
for a in A:
    C[a]+=1

if N % 2 == 0:
    for i,c in enumerate(C):
        if i % 2 == 0:
            continue
        if C[i] != 2 :
            print("0")
            exit()
else:
    for i,c in enumerate(C):
        #print(i,c)
        if i % 2 == 1:
            continue
        if i == 0:
            if C[i] != 1:
                print("0")
                exit()
            else:
                continue
        elif C[i] != 2 :
            print("0")
            exit()

print(2**x)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for x in a:
    d[x] += 1
b = [i for i in range(n)[::-1]]
e = all(d[i] == 2 if n % 2 == 0 else d[i] ==
        1 if i == 0 else d[i] == 2 for i in b[::2])
if not e:
    print(0)
    exit()
ans = 1
for v in d.values():
    ans *= v % (10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
import collections


def check(n, a_count):
    if n % 2 == 1:
        if set(a_count.keys()) == set(range(0, n, 2)):
            if a_count[0] == 1 and all([a_count[key] == 2 for key in a_count if key != 0]):
                ans = 2 ** (n // 2)
                return ans
                
    else:
        if set(a_count.keys()) == set(range(1, n, 2)):
            if all([a_count[key] == 2 for key in a_count]):
                ans = 2 ** (n // 2)
                return ans
    return 0


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

a_count = collections.Counter(a)
print(check(n, a_count))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = sorted(map(int, input().split()))
MOD = 10**9 + 7
ok = True
if n % 2 == 0:
    for i in range(n // 2):
        i *= 2
        ok = ls[i] == ls[i + 1] == i + 1
        if not ok:
            break
else:
    ok = ls[0] == 0
    for i in range(n // 2):
        i *= 2
        ok = ls[i + 1] == ls[i + 2] == i + 2
        if not ok:
            break
if not ok:
    print(0)
else:
    print(2**(n // 2))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
mod = 10**9+7
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 2**(N//2)
if N % 2 == 0:
    for i in A:
        if i % 2 == 0:
            ans = 0
    for j in Counter(A).values():
        if j != 2:
            ans = 0
else:
    for i in A:
        if i % 2 != 0:
            ans = 0
    for j,k in Counter(A).items():
        if j != 0 and k != 2:
            ans = 0
    if Counter(A)[0] != 1:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
CA = Counter(A)
SCA = sorted(CA.items(), key=lambda x:x[0])

if len(CA) != ceil(N / 2):
  print(0)
  exit()

if N % 2 == 0:
  for i, j in zip(SCA, range(ceil(N / 2))):
    if not (i[0] == 1 + j * 2 and i[1] == 2):
      print(0)
      exit()
else:
  for i, j in zip(SCA, range(ceil(N / 2))):
    if j == 0:
      if not (i[0] == j * 2 and i[1] == 1 ):
        print(0)
        exit() 
    else:  
      if not (i[0] == j * 2 and i[1] == 2 ):
        print(0)
        exit()
print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = Counter(a)
if n%2 == 0:
    for key in cnt.keys():
        if key%2 and key < n and cnt[key] == 2:
            continue
        else:
            print(0)
            quit()
    print((2**n) % mod)
else:
    for key in cnt.keys():
        if key % 2 == 0 and key < n and cnt[key] == 2:
            continue
        elif key == 0 and cnt[key] == 1:
            continue
        else:
            print(0)
            quit()
    print((2**n) % mod)

Submission status: Wrong Answer

Solution code:
MOD = 10e9+7
n=int(input())
a=sorted(map(int, input().split()))
if n%2: b = [i if not(i%2) else i+1 for i in range(n)]
else: b = [i if i%2 else i+1 for i in range(n)]
if a==b:
  ans = 1
  for i in range(n//2): ans = (ans*2)%MOD
else: ans = 0
print(int(ans))

Submission status: Wrong Answer

Solution code:
def main(): 
  MOD = 10e9+7
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 1
  if n%2:
    if a.pop(0)!=0:print(0);return 0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]==a[j*2+1]==i:
      ans *= 2
      ans %= MOD
    else: print(0);return 0
  print(int(ans))
  
if __name__=="__main__":main()

Submission status: Wrong Answer

Solution code:
def main(): 
  MOD = 10e9+7
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 1
  if n%2:
    if a.pop(0)!=0:print(0);return 0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]==a[j*2+1]==i: ans=(ans*2)%MOD
    else: print(0);return 0
  print(int(ans))
  
if __name__=="__main__":main()

Submission status: Wrong Answer

Solution code:
def main(): 
  MOD = 10e9+7
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 1
  if n%2:
    if a.pop(0)!=0:print(0);return 0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]==a[j*2+1]==i: ans=(ans*2)%MOD
    else: print(0);return 0
  print(ans)
  
if __name__=="__main__":main()

Submission status: Wrong Answer

Solution code:
def main(): 
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 1
  if n%2:
    if a.pop(0)!=0:print(0);return 0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a[j*2]==a[j*2+1]==i: ans*=2
    else: print(0);return 0
  print(ans)
  
if __name__=="__main__":main()

Submission status: Wrong Answer

Solution code:
def main(): 
  n = int(input())
  a = sorted(map(int, input().split()))
  ans = 1
  if n%2:
    if a.pop(0)!=0:print(0);return 0
  i = n%2 - 1
  for j in range(n//2):
    i += 2
    if a.pop(0)==a.pop(0)==i: ans*=2
    else: print(0);return 0
  print(ans)
  
if __name__=="__main__":main()

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

"""
Nが奇数個の場合、
    Aiに奇数の数字があったらNG
    0の数は1つだけ
    2^(N//2)通り

偶数個の場合
    Aiに偶数の数字があったらNG
    0は0個
    2^((N-1)/2)通り→2^(N//2)でOK

同じ数字は2個ある
"""

from collections import Counter
c = Counter(A)

def ng():
    print(0)
    exit()

# 奇数
if N%2 == 1:
    for k, v in c.items():
        if k % 2 == 1:
            ng()

        if k != 0:
            if v != 2:
                ng()

    if c[0] != 1:
            ng()
else:
    for k, v in c.items():
        if k % 2 == 0:
            ng()

        if k != 0:
            if v != 2:
                ng()

    if c[0] != 0:
            ng()

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
a_list = list(map(int, input().split()))

excepted_dict = {}

if N % 2 == 0:
    n = N // 2
    expected_dict = {i * 2 + 1: 2 for i in range(n)}
else:
    n = N // 2
    expected_dict = {i * 2: 2 for i in range(n + 1)}
    expected_dict[0] = 1

counter = collections.Counter(a_list)

if dict(counter) == expected_dict:
    c = 1
    for v in counter.values():
        c *= v
    ans = c
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

if n%2==0:
    evenlists=[]
    for i in range(1,n,2):
        evenlists.append(i)
        evenlists.append(i)
    special=sorted(evenlists)
    
    if special==sorted(lists):
        ans=1
        for i in range(int(n/2)):
            ans=ans*2
            ans=ans%(10**9+3)
        print(ans)
    else:
        print(0)
else:
    oddlists=[]
    for j in range(2,n,2):
        oddlists.append(j)
        oddlists.append(j)
    oddlists.append(0)
    special=sorted(oddlists)
    
    if special==sorted(lists):
        ans=1
        for j in range(int((n-1)/2)):
            ans=ans*2
            ans=ans%(10**9+3)
        print(ans)  
    else:
        print(0)

Submission status: Wrong Answer

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

if n%2==0:
    evenlists=[]
    for i in range(1,n,2):
        evenlists.append(i)
        evenlists.append(i)
    special=sorted(evenlists)
    print(special)
    if special==sorted(lists):
        ans=1
        for i in range(int(n/2)):
            ans=ans*2
            ans=ans%(10**9+3)
        print(ans)
    else:
        print(0)
else:
    oddlists=[]
    for j in range(2,n,2):
        oddlists.append(j)
        oddlists.append(j)
    oddlists.append(0)
    special=sorted(oddlists)
    
    if special==sorted(lists):
        ans=1
        for j in range(int((n-1)/2)):
            ans=ans*2
            ans=ans%(10**9+3)
        print(ans)  
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    for k,v in c.items():
        if(v == 2 or (k == 0 and v == 1)):
            pass
        else:
            print(0)
            exit()
        
    print(2 ** (N//2))


    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    if(N == 1):
        print(1)
        exit()

    for k,v in c.items():
        if(v == 2 or (k == 0 and v == 1)):
            pass
        else:
            print(0)
            exit()
        
    print(2 ** (len(A)//2))


    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    for k,v in c.items():
        if(v == 2 or (k == 0 and v == 1)):
            pass
        else:
            print(0)
            exit()
        
    print(2 ** (len(A)//2))


    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()