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 math
n = int(input())

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

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



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


if n % 2 == 1:
    for i in range(n):
        if i == 0:
            if a[i] == 0:
                continue
            else:
                print(0)
                exit()
        else:
            if a[i] == math.ceil(i/2)*2:
                continue
            else:
                print(0)
                exit()
else:
    for i in range(n):
        if a[i] == math.floor(i/2)*2+1:
            continue
        else:
            print(0)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

if n % 2 == 1:
    ans = 2 ** ((n-1) // 2)
else:
    ans = 2 ** (n//2)
if n % 2 == 1:
    for i in range(n):
        if i == 0:
            if a[i] == 0:
                continue
            else:
                print(0)
                exit()
        else:
            if a[i] == math.ceil(i/2)*2:
                continue
            else:
                print(0)
                exit()
else:
    for i in range(n):
        if a[i] == math.floor(i/2)*2+1:
            continue
        else:
            print(0)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = [int(i) for i in input().split()]
if a.count(0) >= 2:
    print(0)
    sys.exit()
if 0 in a:
    a.remove(0)
b = set(a)
print((2**(len(b))%(10**9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
test = [abs(n - (2*k + 1)) for k in range(n)]
if(sorted(a) == sorted(test)):
	print(pow(2, int(n/2))) 
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = [int(i) for i in input().split()]
count = collections.Counter(A)
ans = 0
if N%2 == 1:
  for k,v in count.items():
    if k%2 == 1 or (k != 0 and v != 2):
      break
  else:
    ans = 2**(N//2)
else:
  for k,v in count.items():
    if k%2 == 0 or v != 2:
      break
    else:
      ans = 2**(N//2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
A = map(int, raw_input().split())
A.sort(reverse=True)
success = True
el = n - 1
for i in range(0, len(A)-1, 2):
    if A[i] != el or A[i+1] != el:
        success = False
        break
    el -= 2
if n % 2 == 1:
    if A[-1] != 0:
        success = False
else:
    if A[-1] != 1 or A[-2] != 1:
        success = False
if success:
    print 2**(n/2)
else:
    print 0

Submission status: Wrong Answer

Solution code:
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

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

Submission status: Wrong Answer

Solution code:
from math import ceil
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A.sort()

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

Submission status: Wrong Answer

Solution code:
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort()
N = int(N)
flag = True
num = 2
if N %2 != 0:
    if l[0] != 0:
        flag =False
    num = 2
    start = 1
else:
    num = 1
    start = 0
for i in range(start,N,2):
    if l[i] != l[i + 1]   or l[i] != num:
        flag = False
    else:
        num += 2 
if flag:
    temp = (N - start)//2
    print(2 ** temp)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import itertools
N = input()
l = list(map(int,input().split(" ")))
l.sort()
N = int(N)
flag = True
num = 2
if N %2 != 0:
    if l[0] != 0:
        flag =False
    num = 2
    start = 1
else:
    num = 1
    start = 0
for i in range(start,N,2):
    if l[i] != l[i + 1]:
        flag = False
if flag:
    temp = (N - start)//2
    print(2 ** temp)
else:
    print(0)

Submission status: Wrong Answer

Solution code:

N = int(input())

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

dic = {}


for i in A:

    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

#print(dic)

if N % 2 == 0:

    flag = True
    now = 1

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break

        now += 2

    if len(dic) != N // 2:
        flag = False

    if flag:
        print (2 ** (N // 2))

    else:
        print (0)

else:

    flag = True
    now = 2

    if 0 not in dic or dic[0] != 1:
        flag = False

    for i in range(N // 2):

        if now not in dic or dic[now] != 2:
            flag = False
            break
        now += 2

    if flag:
        print (2 ** (N // 2))

    else:
        print (0)

Submission status: Wrong Answer

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

def judge() :
    c = [0] * ((N + 1) // 2)
    p = N % 2

    for a in A :
        if a % 2 == p or a < 0 or N <= a :
            return 0
            
        c[a//2] += 1
 
    if p == 1 and c[0] == 1 and c[1:].count(2) == (N - 1) // 2 :
        return 2 ** ((N - 1) // 2)
    
    elif p == 0 and c.count(2) == N // 2 :
        return 2 ** (N // 2)
        
    return 0
    
print(judge())

Submission status: Wrong Answer

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

def judge() :
    c = [0] * ((N + 1) // 2)
    p = N % 2

    for a in A :
        if a % 2 == p or a < 0 or N <= a :
            return 0
            
        c[a//2] += 1
 
    if p == 1 and c[0] == 1 and c[1:].count(2) == (N - 1) // 2 :
        return 2 ** (N // 2)
    
    elif p == 0 and c.count(2) == N // 2 :
        return 2 ** (N // 2)
        
    return 0
    
print(judge())

Submission status: Wrong Answer

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

def judge() :
    c = [0] * ((N + 1) // 2)
    p = N % 2

    for a in A :
        if a % 2 == p or a < 0 or N <= a :
            return 0
            
        c[a//2] += 1
 
    if p == 1 and c[0] == 1 and c[1:].count(2) == N // 2 :
        return 2 ** (N // 2)
    
    elif p == 0 and c.count(2) == N // 2 :
        return 2 ** (N // 2)
        
    return 0
    
print(judge())

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(map(int,input().split()))
B = []

if N%2:
	B = [0]
	for i in range(N//2):
		B += [(i + 1)*2]*2
else:
	for i in range(N//2):
		B += [i*2 + 1]*2	
print(A, B)
print(B)
if A==B:
	print(2**(N//2)%((10**9) + 7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(map(int,input().split()))
B = []

if N%2:
	B = []
	for i in range(N//2):
		B += [(i + 1)*2]*2
else:
	for i in range(N//2):
		B += [i*2 + 1]*2	
#print(A, B)
#print(B)
if A==B:
	print(2**(N//2)%((10**9) + 7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(map(int,input().split()))
B = []

if N%2:
	B = []
	for i in range(N//2):
		B += [(i + 1)*2]*2
else:
	for i in range(N//2):
		B += [i*2 + 1]*2	
print(A, B)
print(B)
if A==B:
	print(2**(N//2)%((10**9) + 7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""

if N%2:
	B += "0"
	for i in range(N//2):
		B += str((i + 1)*2)*2
else:
	for i in range(N//2):
		B += str(i*2 + 1)*2	
#print(A, B)
if A==B:
	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()
i = 0
res = 0
if N == 1:
  if A[0] == 0:
    print(1)
  else:
    print(0)
  exit(0)
if N % 2 == 1:
  res = 1
  i = 1
  if A[0] == A[1]:
    print(0)
    exit(0)
  if A[0] == 1:
    print(0)
    exit(0)
else:
  res = 2
  i = 2
  if A[0] != A[1]:
    print(0)
    exit(0)
  if A[0] == 0:
    print(0)
    exit(0)
while i < N - 1:
  if A[i] == A[i + 1]:
    if N % 2 == 0:
      if A[i] != 2 * (i / 2 + 1) - 1:
        res = 0
        break
    else:
      if A[i] != 2 * (i // 2 + 1):
        res = 0
        break
    res *= 2
    i += 2
  else:
    res = 0
    break
print(res)

Submission status: Wrong Answer

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

A.sort()
i = 0
res = 0
if N == 1:
  if A[0] == 1:
    print(1)
  else:
    print(0)
  exit(0)
if N % 2 == 1:
  res = 1
  i = 1
  if A[0] == A[1]:
    print(0)
    exit(0)
  if A[0] == 1:
    print(0)
    exit(0)
else:
  res = 2
  i = 2
  if A[0] != A[1]:
    print(0)
    exit(0)
  if A[0] == 0:
    print(0)
    exit(0)
while i < N - 1:
  if A[i] == A[i + 1]:
    if N % 2 == 0:
      if A[i] != 2 * (i / 2 + 1) - 1:
        res = 0
        break
    else:
      if A[i] != 2 * (i // 2 + 1):
        res = 0
        break
    res *= 2
    i += 2
  else:
    res = 0
    break
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC50 C

from collections import Counter
from operator import itemgetter

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

c = Counter(a)
c = list(c.items())
ccc = sorted(c,key = itemgetter(0))
if n % 2 == 1:
    k = 0
    for i,j in ccc:
        if j == 2 and i % 2 == 0 and i == 2*k:
            k += 1
            continue
        if j == 1 and i == 0:
            k += 1
            continue
        else:
            print(0)
            quit()
if n % 2 == 0:
    k = 0
    for i,j in ccc:
        if j == 2 and i % 2 == 1 and i == 2*k+1:
            k += 1
            continue
        else:
            print(0)
            quit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""

if N%2:
	B += "0"
	for i in range(N//2):
		B += str((i + 1)*2)*2
else:
	for i in range(N//2):
		B += str(i*2 + 1)*2	
#print(A, B)
if A==B:
	print(2**(N//2)%((10**9) + 7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""

if N%2:
	B += "0"
	for i in range(2, N+1, 2):
		B += str(i)*2
else:
	for i in range(1, N+1, 2):
		B += str(i)*2	
#print(A, B)
if A==B:
	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(reverse = True)
if N % 2 == 1:
  if A.count(A[-1]) == 0:
    print(0)
    exit(0)
else:
  if A.count(A[-1]) == 1:
    print(0)
    exit(0)
res = 1
i = 0
while i < N - 1:
  if A[i] == A[i + 1]:
    res *= 2
    i += 2
  else:
    res = 0
    break
print(res)

Submission status: Wrong Answer

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

res = 1
temp = []
mid = 0
for i in range(N):
  if A.count(A[i]) == 2:
    if A[i] in temp:
      continue
    res *= 2
  else:
    if N % 2 == 1:
      if mid == 0:
        mid = 1
        continue
    if i == N - 1:
      continue
    res = 0
    break
  temp.append(A[i])
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""
if N%2:
	B += "0"
	for i in range(N//2):
		B += str((i+1)*2)*2
else:
	for i in range(N//2):
		B += str(i*2 + 1)*2	
#print(A, B)
if A==B:
	print((2**(N//2))%(10**9+7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""
if N%2:
	B += "0"
	for i in range(N//2):
		B += str((i+1)*2)*2
else:
	for i in range(N//2):
		B += str(i*2 + 1)*2	
#print(A, B)
if A==B:
	print(2**(N//2))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = "".join(sorted(input().split()))
B = ""
if N%2:
	B += "0"
	for i in range(N//2):
		B += str((i+1)*2)*2
else:
	for i in range(N//2):
		B += str(i*2 + 1)*2	
if A==B:
	print((N//2)**2)
else:
	print(0)

Submission status: Wrong Answer

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

l = {}
ll = {}

if n % 2 == 0:
  for i in m:
    l[2*(i//2)+1] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1
else:
  for i in m:
    if 2*(i//2) == 0:
      l[2*(i//2)] = 1
    else:
      l[2*(i//2)] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1

if l != ll:
  print(0)
  exit()

print(1 << (n // 2) % ((10 ** 9) + 7))

Submission status: Wrong Answer

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

l = {}
ll = {}

if n % 2 == 0:
  for i in m:
    l[2*(i//2)+1] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1
else:
  for i in m:
    if 2*(i//2) == 0:
      l[2*(i//2)] = 1
    else:
      l[2*(i//2)] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1

if l != ll:
  print(0)
  exit()

print(1 << (n // 2) % (10**9+7))

Submission status: Wrong Answer

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

l = {}
ll = {}

if n % 2 == 0:
  for i in m:
    l[2*(i//2)+1] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1
else:
  for i in m:
    if 2*(i//2) == 0:
      l[2*(i//2)] = 1
    else:
      l[2*(i//2)] = 2
    if i in ll:
      ll[i] += 1
    else:
      ll[i] = 1

if l != ll:
  print(0)
  exit()

print(1 << (n // 2))

Submission status: Wrong Answer

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

l = {}

if n % 2 == 0:
  for i in m:
    if i <= 0 or i >  n or i % 2 == 0:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2:
      print(0)
      exit()
else:
  for i in m:
    if i < 0 or i > n or i % 2 == 1:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2 or (i == 0 and l[i] > 1):
      print(0)
      exit()

print(1 << (n // 2))

Submission status: Wrong Answer

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

l = {}

if n % 2 == 0:
  for i in m:
    if i <= 0 and i >  n and i % 2 == 1:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2:
      print(0)
      exit()
else:
  for i in m:
    if i < 0 and i > n and i % 2 == 0:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2 or (i == 0 and l[i] > 1):
      print(0)
      exit()

print(1 << (n // 2))

Submission status: Wrong Answer

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

l = {}

if n % 2 == 0:
  for i in m:
    if i <= 0 and i >  n and i % 2 == 0:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2:
      print(0)
      exit()
else:
  for i in m:
    if i < 0 and i > n and i % 2 == 1:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2 or (i == 0 and l[i] > 1):
      print(0)
      exit()

print(1 << (n // 2))

Submission status: Wrong Answer

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

l = {}

if n % 2 == 0:
  for i in m:
    if i < 0 and i > n and i % 2 == 0:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2:
      print(0)
      exit()
else:
  for i in m:
    if i < 0 and i > n and i % 2 == 1:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2 or (i == 0 and l[i] > 1):
      print(0)
      exit()

print(1 << (n // 2))

Submission status: Wrong Answer

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

l = {}

if n % 2 == 0:
  for i in m:
    if i < 0 and i > n and i % 2 == 0:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2:
      print(0)
      exit()
else:
  for i in m:
    if i < 0 and i > n and i % 2 == 1:
      print(0)
      exit()
    if i in l:
      l[i] += 1
    else:
      l[i] = 1
    if l[i] > 2 or (i == 0 and l[i] > 1):
      print(0)
      exit()

print(l)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    # if i==0 and kakunin[0]==1 and kigu==1:
    #     continue
    # if kigu!=i%2 and kakunin[i]!=2:
    #     print(0)
    #     quit()
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(0)
            quit()
        elif i!=0 and kakunin[i]!=2:
            print(0)
            quit()

print((2**(n//2))%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    # if i==0 and kakunin[0]==1 and kigu==1:
    #     continue
    # if kigu!=i%2 and kakunin[i]!=2:
    #     print(0)
    #     quit()
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(0)
            quit()
        elif i!=0 and kakunin[i]!=2:
            print(0)
            quit()

print(2**(n//2)%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    # if i==0 and kakunin[0]==1 and kigu==1:
    #     continue
    # if kigu!=i%2 and kakunin[i]!=2:
    #     print(0)
    #     quit()
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(8)
            print(0)
            quit()
        elif i!=0 and kakunin[i]!=2:
            print(i)
            print(0)
            quit()

print(2**(n//2)%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    # if i==0 and kakunin[0]==1 and kigu==1:
    #     continue
    # if kigu!=i%2 and kakunin[i]!=2:
    #     print(0)
    #     quit()
    if kigu==0 and i%2==1:
        if kakunin[i]!=2:
            print(0)
            quit()
    if kigu==1 and i%2==0:
        if i==0 and kakunin[i]!=1:
            print(0)
            quit()
        if kakunin[i]!=2:
            print(0)
            quit()

print(2**(n//2)%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    if i==0 and kakunin[0]==1 and kigu==1:
        continue
    if kigu!=i%2:
        if kakunin[i]!=2:
            print(0)
            quit()

print(2**(n//2)%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    if i==0 and kakunin[0]==1:
        continue
    if kigu!=i%2:
        if kakunin[i]!=2:
            print(0)
            quit()

print(2**(n//2)%waru)

Submission status: Wrong Answer

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

waru=10**9+7

kakunin=[0]*n
kigu=n%2
for i in range(n):
    if kigu==a[i]%2:
        print(0)
        quit
    kakunin[a[i]]+=1

for i in range(n):
    if i==0 and kakunin[0]==1:
        continue
    if kigu!=i%2:
        if kakunin[i]!=2:
            print(0)
            quit()

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

Submission status: Wrong Answer

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

sum_a = 0
ans = 0
for i in a:
    sum_a += i

if n % 2 == 0:
    
    for i in a:
        if i % 2 == 0:
            print(0)
            exit(0)

    if (n * (n // 2)) == sum_a:
        ans = (n // 2) ** 2

else:
    
    for i in a:
        if i % 2 == 1:
            print(0)
            exit(0)

    if ((n - 1) * (n + 1) // 2) == sum_a:
        ans = ((n - 1) // 2 )** 2
print(ans % (10**9 + 7))

Submission status: Wrong Answer

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

sum_a = 0
ans = 0
for i in a:
    sum_a += i

if n % 2 == 0:
    
    for i in a:
        if i % 2 == 0:
            print(0)
            exit(0)

    if (n * (n // 2)) == sum_a:
        ans = (n // 2) ** 2

else:
    
    for i in a:
        if i % 2 == 1:
            print(0)
            exit(0)

    if ((n - 1) * (n + 1) // 2) == sum_a:
        ans = ((n - 1) // 2 )** 2
print(ans % 10**9 + 7)

Submission status: Wrong Answer

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

sum_a = 0
ans = 0
for i in a:
    sum_a += i

if n % 2 == 0:
    
    for i in a:
        if i % 2 == 0:
            print(0)
            exit(0)

    if (n * (n // 2)) == sum_a:
        ans = (n // 2) ** 2

else:
    
    for i in a:
        if i % 2 == 1:
            print(0)
            exit(0)

    if ((n - 1) * (n + 1) // 2) == sum_a:
        ans = ((n - 1) // 2 )** 2
print(ans)

Submission status: Wrong Answer

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

sum_a = 0
ans = 0
for i in a:
    sum_a += i

if n % 2 == 0:
    
    for i in a:
        if i % 2 == 0:
            print(0)
            exit(0)

    if (n * (n // 2)) == sum_a:
        ans = (n // 2) ** 2

else:
    
    for i in a:
        if i % 2 == 1:
            print(0)
            exit(0)

    if ((n - 1) * (n + 1) // 2) == sum_a:
        ans = ((n - 1) // 2 )** 2
print("test")
print(ans)

Submission status: Wrong Answer

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

sum_a = 0
ans = 0
for i in a:
    sum_a += i

if n % 2 == 0:
    if (n * (n // 2)) == sum_a:
        ans = (n // 2) ** 2

else:
    if ((n - 1) * (n + 1) // 2) == sum_a:
        ans = ((n - 1) // 2 )** 2
print(ans)

Submission status: Wrong Answer

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

for i in range(N):
    if A.count(i) == 2 and i != 0:
        c += 1
    elif A.count(i) == 1 and i == 0:
        continue
    elif A.count(i) == 0:
        continue
    else:
        break
    
print((c**2) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
c = 0

for i in range(N):
    if A.count(i) == 2 and i != 0:
        c += 1
    elif A.count(i) == 1 and i == 0:
        continue
    elif A.count(i) == 0:
        continue
    else:
        break

print(c**2)

Submission status: Wrong Answer

Solution code:
# 前の回答が気に食わなかったのでもう一回

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

for i, a in enumerate(A):
    if N % 2 == 0:
        if a != i // 2 * 2 + 1:
            print(0)
            exit()
    else:
        if a != (i + 1) // 2 * 2:
            print(0)
            exit()

print(int((2 ** (N // 2)) % (10*9 + 7)))

Submission status: Wrong Answer

Solution code:
# 前の回答が気に食わなかったのでもう一回

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

for i, a in enumerate(A):
    if N % 2 == 0:
        if a != i // 2 * 2 + 1:
            print(0)
            exit()
    else:
        if a != i // 2 * 2:
            print(0)
            exit()

print(int((2 ** (N // 2)) % (10*9 + 7)))

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]
m = [set() for _ in range(N)]

t = N - 1
for i in range(N):
    v = L[i]
    e = (t + v) // 2
    s = t - e
    
    m[s].add(i)
    m[e].add(i)
    
l = set()
for v in m:
    if len(v) == 0:
        print("-1")
        exit()
    elif len(v) == 1:
        v = list(v)
        if v[0] in l:
            print("-1")
            exit()
        
        l.add(v[0])
        
c = (N - len(l)) // 2
print(2 ** c % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
absL = list(input().split())

ans = 0

if N % 2 == 1:
    if absL.count("0") == 1:
        for i in range((N - 1)//2):
            if absL.count(str((i + 1) * 2)) != 2:
                exit()
        
        ans = 2 ** (N // 2)
        
if N % 2 == 0:
    if absL.count("0") == 0:
        for i in range(N // 2):
            if absL.count(str((i * 2) + 1)) != 2:
                exit()
        
        ans = 2 ** (N // 2)
        
print(int((ans % ((10**9) + 7))))

Submission status: Wrong Answer

Solution code:
N = int(input())
absL = list(input().split())

ans = 2 ** (N // 2)

if N % 2 == 1:
    if absL.count("0") != 1:
        ans = 0
    else:
        for i in range((N - 1)//2):
            if absL.count(str((i + 1) * 2)) != 2:
                ans = 0
                exit()
        
if N % 2 == 0:
    if absL.count("0") != 0:
        ans = 0
    else:
        for i in range(N // 2):
            if absL.count(str((i * 2) + 1)) != 2:
                ans = 0
                exit()
        
print(int((ans % ((10**9) + 7))))

Submission status: Wrong Answer

Solution code:
N = int(input())
absL = list(input().split())

ans = 2 ** (N // 2)

if N % 2 == 1:
    if absL.count("0") != 1:
        for i in range((N - 1)//2):
            if absL.count(str((i + 1) * 2)) != 2:
                ans = 0
                exit()
        
if N % 2 == 0:
    if absL.count("0") != 0:
        for i in range(N // 2):
            if absL.count(str((i * 2) + 1)) != 2:
                ans = 0
                exit()
        
print(int((ans % ((10**9) + 7))))

Submission status: Wrong Answer

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

a = int((N - 1)// 2)
b = int(N/2)

if N % 2 == 0:
    for i in range(0, N, 2):
        if A[i] == 1 + i:
            num = 2 ** b % (10 ** 9 +7)
        else:
            num = 0
            break
else:
    for i in range(0, N, 2):
        if A[i] == i :
            num = int(2 ** (a)) % (10 ** 9 +7)
        else:
            num = 0
            break
print(num)

Submission status: Wrong Answer

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

a = int((N - 1)// 2)
b = int(N/2)

if N % 2 == 0:
    for i in range(0, N, 2):
        if A[i] == 1 + i:
            num = 2 ** b % (10 ** 9 +7)
        else:
            num = 0
else:
    for i in range(0, N, 2):
        if A[i] == i :
            num = int(2 ** (a)) % (10 ** 9 +7)
        else:
            num = 0
print(num)

Submission status: Wrong Answer

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

a = int((N - 1)// 2)
b = int(N/2)

if N % 2 == 0:
    for i in range(0, N, 2):
        if A[i] == 1 + i:
            num = 2 ** b
        else:
            num = 0
else:
    for i in range(0, N, 2):
        if A[i] == i :
            num = int(2 ** (a))
        else:
            num = 0
print(num)

Submission status: Wrong Answer

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


def mod_power(x, a, p):
    if a == 0:
        return 1
    t = mod_power(x, a // 2, p)
    if a % 2 == 0:
        return t * t
    else:
        return x * t % p * t

print(mod_power(2,n//2,10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list((int(x) for x in input().split()))


if n % 2 == 1:  # 奇数
    if a.count(0) == 1:
        if sum(a) == (n + 1) * 2:
            print((2 ** (n // 2)) % ((10 ** 9) + 7))
            exit()
        else:
            print(0)
            exit()

else:  # 偶数
    if sum(a) == (n + 1) * 2:
        print((2 ** (n // 2)) % ((10 ** 9) + 7))
        exit()
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int, input().split(" ")))
a_num = [N-i for i in range(1, N, 2)]
aa = a[::]
if sum(a) == (sum(a_num)*2):
    lst = collections.Counter(aa)
    if max(lst.values()) == 2:
        print(pow(N // 2, 2) % (10 ** 9 + 7))
    else:
        print("0")
else:
    print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list((int(x) for x in input().split()))

oops = 0

if n % 2 == 1:  # 奇数
    if a.count(0) >= 2:
        oops = 1
        print(0)
        exit()
    elif 0 in a:  # 中央値あれば
        a.remove(0)  # 消す
        print(a)
        n -= 1
    else:
        print("a")
        oops = 1  # ないならエラー

    # 奇数
    print("n - 1", (n - 1))
    for i in range(2, n, 2):
        if a.count(i) != 2:
            oops = 1
            print("i", i)
            print("b")
            break

else:
    for i in range(1, n, 2):
        if a.count(i) != 2:
            oops = 1
            break

if oops == 1:
    print(0)
    exit()
print(n)
print((2 ** (n // 2)))
# print((2 ** (n // 2)) % ((10 ** 9) + 7))