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:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    if a[0] == 0:
        t = 2
        for i in range(2, n, 2):
            if a[i] != a[i-1] or a[i] != t:
                print(0)
                exit()
            t += 2
        print(2 ** ((len(a) - 1) // 2))
    else:
        t = 1
        for i in range(1, n, 2):
            if a[i] != a[i-1]:
                print(0)
                exit()
            t += 2
        print(2 ** (len(a) // 2))


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

f=True
if N%2!=0:
	idx=1
	x=2
	if A[0]!=0:f=False
else:
	idx=0
	x=1
print(A)
for i in range(N//2):
	print(idx)
	if A[idx]!=x or A[idx+1]!=x:
		f=False
	idx+=2
	x+=2

if f: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()

f=True
if N%2!=0:
	idx=1
	x=2
	if A[0]!=0:f=False
else:
	idx=0
	x=1

for i in range(N//2):
	if A[idx]!=x or A[idx+1]!=x:
		f=False
	idx+=2
	x+=2

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted([int(x) for x in input().split(' ')])


if n % 2 == 1:
    a = a[1:]
    base = 2
else:
    base = 1

for i in range(1, len(a), 2):
    if not (a[i-1] == a[i] == base):
        print(0)
        exit()
    base += 2

print(2**(len(a)//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

c = Counter(a)
for k, v in c.items():
    if (k != 0 and v != 2) or (k == 0 and v != 1):
        print(0)
        break

else: print(2**(n//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
tru = 0
acount = Counter(a)
if n == 1:
         if a == 1:
                  print(1)
         else:
                  print(0)
elif n % 2 == 1:
         for i in range (1,n//2+1):
                  if acount[i*2] != 2:
                           print(0)
                           exit()
         else:
                  if acount[0] != 1:
                           print(0)
                           exit()
                  else:
                           print((2 ** (n//2) ) % (10 ** 9 + 7))
else:
         for j in range(1,n//2+1):
                  if acount[j*2-1] != 2:
                           print(0)
                           exit()
         else:
                  print((2 ** (n//2) ) % (10 ** 9 + 7))

Submission status: Wrong Answer

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

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

if A != S:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    cnt = 0
    if n % 2 == 0:
        m = 1
        for i in range(1, n, 2):
            if not a[i] == a[i - 1] == m:
                print(0)
                exit()
            m += 2
            cnt += 1
    else:
        m = 0
        for i in range(0, n, 2):
            if i == 0:
                if not a[i] == m:
                    print(0)
                    exit()
            else:
                if not a[i] == a[i-1] == m:
                    print(0)
                    exit()
                cnt += 1
            m += 2
    print(2 ** cnt)


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2:
    for i in ac.items():
        if i[0] == 0:
            if i[1] != 1:
                print(0)
                exit()
        else:
            if i[1] != 2:
                print(0)
                exit()
    print(2 ** (n // 2))
else:
    for i in ac.values():
        if i != 2:
            print(0)
            exit()
    print(2 ** (n // 2))

Submission status: Wrong Answer

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

def is_valid(A):
    counts = {}
    for a in A:
        if a in counts:
            counts[a] += 1
        else:
            counts[a] = 1
    if len(A) % 2 == 1:
        if counts[0] != 1:
            return False
        
        for i in range(1, len(A) // 2 + 1):
            if 2 * i not in counts or counts[2 * i] != 2:
                return False
        return True
    else:
        for i in range(1, len(A) // 2 + 1):
            if 2 * i - 1 not in counts or counts[2 * i - 1] != 2:
                return False
        return True
    return True
        
if is_valid(A):
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# 2019/08/11

from collections import Counter

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

c=Counter(a)

if c.most_common(1)[0][1]>2 or c[0]>1:
    print(0)
    exit()

for k,v in c.items():
    if k!=0 and v!=2:
        print(0)
        exit()
    if n%2==k%2:
        print(0)
        exit()
        
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
# 2019/08/11

from collections import Counter

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

c=Counter(a)

if c.most_common(1)[0][1]>2 or c[0]>1:
    print(0)
    exit()

for k,v in c.items():
    if k!=0 and v!=2:
        print(0)
        exit()
    if n%2==v%2:
        print(0)
        exit()
        
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
import collections
import math

mod = int(1e9 + 7)
n = int(input())
a = list(map(int,input().split()))

c = collections.Counter(a)
if n%2 == 0:
    check = True
    for i in range(n//2):
        if c[1+2*i] != 2:
            check = False
    if check:
        print(pow(2,n//2,mod))
    else:
        print(0)
else:
    if c[0] == 1:
        check = True
    else:
        check = False
    for i in range(1,n//2+1):
        if c[2**i] != 2:
            check = False
    if check:
        print(pow(2,n//2,mod))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import collections
mod = int(1e9 + 7)
n = int(input())
a = list(map(int,input().split()))

c = collections.Counter(a)
if n%2 == 0:
    check = True
    for i in range(n//2):
        if c[1+2*i] != 2:
            check = False
    if check:
        print(2**(n//2)%mod)
    else:
        print(0)
else:
    if c[0] == 1:
        check = True
    else:
        check = False
    for i in range(1,n//2+1):
        if c[2**i] != 2:
            check = False
    if check:
        print(2**(n//2)%mod)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ARC66C
import sys

n=int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

a=[]
for i in range(0,(n+1)//2):
	a.append(0)
for i in range(0,n):
	a[hoge[i]//2]+=1

if(a[0]%2!=n%2):
	print(0)
else:
	for i in range(1,(n+1)//2):
		if(a[i]!=2):
			print(0)
			sys.exit()
	print(max(a[0],1)*pow(2,(n-1)//2))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
b.sort()
if a % 2 == 0:
    c = 1
    for i in range(len(b)):
        if i > 0 and i % 2 == 0:
            c += 2
        if b[i] != c:
            print(0)
            exit()
    print(2 ** (a // 2))
else:
    c = 0
    for i in range(len(b)):
        if i > 0 and i % 2 == 1:
            c += 2
        if b[i] != c:
            print(0)
            exit()
    print(2 ** ((a-1) // 2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [2]*n
dp[0] = 1
mod = 10**9+7
an = [int(i) for i in input().split()]

if n % 2 == 1:
  for i in an:
    if i % 2 == 1 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**((n-1)//2)//mod)
else:
  for i in an:
    if i % 2 == 0 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**(n//2)//mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
dp = [2]*n
dp[0] = 1
an = [int(i) for i in input().split()]

if n % 2 == 1:
  for i in an:
    if i % 2 == 1 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**((n-1)//2))
else:
  for i in an:
    if i % 2 == 0 or dp[i] == 0:
      print(0)
      exit()
    else:
      dp[i] -= 1
  print(2**(n//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 1
if n%2 == 1:
    for i in range(n):
        if a[i] != ((i+1)//2)*2:
            ans = 0
            break
        elif i %2 == 0 and i != 0:
            ans = (ans * 2)%(10**9+7)
else:
    for i in range(n):
        if a[i] != (i//2)*2+1:
            ans = 0
            break
        elif i %2 == 1:
            ans *= (ans * 2)%(10**9+7)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 1
if n%2 == 1:
    for i in range(n):
        if a[i] != ((i+1)//2)*2:
            ans = 0
            break
        elif i %2 == 0 and i != 0:
            ans *= 2
else:
    for i in range(n):
        if a[i] != (i//2)*2+1:
            ans = 0
            break
        elif i %2 == 1:
            ans *= 2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
if(N==1):
    if(A[0]==0):
        print(1)
    else:
        print(0)
else:
    for i in A:
        if(i not in di):
            di[i]=1
        else:
            di[i]+=1
    for i in range(N//2):
        if(i+c==0):
            if(0 not in di):
                flag = False
            else:
                flag &= (di[i]==1)
        else:
            if(0 not in di):
                flag = False
            else:
                flag &= (di[i*2+c]==2)
        if(not flag):
            print(0)
            break
    else:
        print((2<<(N//2-1))%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
for i in range(N//2):
    if(i+c==0):
        flag &= (A.count(i)==1)
    else:
        flag &= (A.count(i*2+c)==2)
    if(not flag):
        print(0)
        break
else:
    print(((N//2)**2)%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
c = 1-N%2
flag = True
for i in range(N//2):
    if(i+c==0):
        flag &= (A.count(i)==1)
    else:
        flag &= (A.count(i*2+c)==2)
    if(not flag):
        print(0)
        break
else:
    print((N//2)**2)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

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

p = N//2
print(2**p)

Submission status: Wrong Answer

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

import collections
c=collections.Counter(a)
l=len(c)
ans=1
for i in range((n-1)%2,n,2):
    if i==0:
        if c[i]!=1:
            ans*=0
    elif c[i]==2:
        ans*=2
    ans=ans%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

import collections
c=collections.Counter(a)
l=len(c)

if 2*l==n:
    print(pow(2,l,10**9+7))
else:
    print(pow(2,l-1,10**9+7))

Submission status: Wrong Answer

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

def check():
    if A.count(0) != 1: return 0
    else:
        if N % 2 == 0:
            for i in range(1,N)[::2]:
                if A.count(i) != 2: return 0
            return (2**(N/2)) % (1e9+7)
        else:
            for i in range(2,N)[::2]:
                if A.count(i) != 2: return 0
            return (2**((N-1)/2)) % (1e9+7)
        
print(int(check()))

Submission status: Wrong Answer

Solution code:
"""
自分の左に並んでいた人数と自分の右に並んでいた人数の差の絶対値はAi
元の並び方が何通りあるか

N = 3
並び    1 2 3
As      2 0 2

N = 4
並び    1 2 3 4
As      3 1 1 3

2^n通りだろう
"""
N = int(input())
As = list(map(int,input().split()))
As = sorted(As)

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

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
      else:
        print(0)
        break
    else:print(2**(a//2))
  else:
    tttt = x.pop()
    if tttt != 0:
      print(0)
      exit()
    for i in range(0,a-2,2):
      if i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
      else:
        print(0)
        break

    else:print(2**(a//2))

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and not i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))
  else:
    tttt = x.pop()
    if tttt != 0:
      print(0)
      exit()
    for i in range(0,a-2,2):
      if not i == x[-1] and not i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))

Submission status: Wrong Answer

Solution code:


a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))
  else:
    tttt = x.pop()
    if tttt != 0:
      print(0)
      exit()
    for i in range(0,a-2,2):
      if not i == x[-1] and i ==x[-2]:
        print(0)
        break
      x.pop()
      x.pop()
    else:print(2**(a//2))

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))
  else:
    if x.pop() != 0:
      print(0)
      exit()
    for i in range(0,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))

Submission status: Wrong Answer

Solution code:
a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))
  else:
    for i in range(0,a,2):
      if x.pop() != 0:
        print(0)
        exit()
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))

Submission status: Wrong Answer

Solution code:

a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a == 1:
  if x[0] == 0:print(1)
  else:print(0)
else:
  if a %2 == 0:
    for i in range(1,a,2):
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))
  else:
    for i in range(0,a,2):
      x.pop()
      if not i == x[-1] and i ==x[-2]:
        x.pop()
        x.pop()
        print(0)
        break
    else:print(2**(a//2))

Submission status: Wrong Answer

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

A.sort(reverse=True)

if N % 2 == 1:
    if A[-1] == 0:
        A.pop()
    else:
        print(0)
        quit()

for i in range(0, N - 2, 2):
    if A[i] != N - i - 1 or A[i] != A[i + 1]:
        print(0)
        quit()

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

Submission status: Wrong Answer

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

A.sort(reverse=True)

if N % 2 == 1:
    A.pop()

for i in range(0, N - 2, 2):
    if A[i] != N - i - 1 or A[i] != A[i + 1]:
        print(0)
        quit()

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

Submission status: Wrong Answer

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

cnt = dict()

for i in range(n):
    cnt[i] = 0
for d in dat:
    cnt[d]+=1

if n%2:
    if cnt[0] != 1:
        print(0)
        exit(0)
    for i in range(2,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
else:
    for i in range(1,n,2):
        if cnt[i] != 2:
            print(0)
            exit(0)
print(2**(n//2))

Submission status: Wrong Answer

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

num = [0] * N
for i in A:
    num[i] += 1

ans = 0
if N % 2 == 0:
    flag = True
    for i in range(N):
        if (i % 2 == 0 and num[i] != 0) or (i % 2 == 1 and num[i] != 2):
            flag = False
    if flag:
        ans = 2 ** (N//2)
else:
    flag = True
    for i in range(N):
        if num[0] != 1 or (i != 0 and i % 2 == 0 and num[i] != 2) or (i % 2 == 1 and num[i] != 0):
            flag = False
    if flag:
        ans = 2 ** (N//2)

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter


N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
ans = 0

if N % 2:
    if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
        ans = pow(2, N//2) // mod
else:
    if all(countA[i] == 2 for i in range(1, N, 2)):
        ans = pow(2, N//2) // mod


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
from collections import Counter
C = Counter(a)
if n%2==0 and not a.count(0)==0:
    print(0)
    exit()
elif n%2==1 and not a.count(0)==1:
    print(0)
    exit()
for c in set(a):
    if not c==0 and not C[c]==2:
        print(0)
        exit()
print(1<<(n//2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
from collections import Counter
C = Counter(a)
if n%2==0 and not a.count(0)==0:
    print(0)
    exit()
elif n%2==1 and not a.count(0)==1:
    print(0)
    exit()
for c in set(a):
    if not c==0 and not C[c]==2:
        print(0)
        exit()
print(1<<(n//2))

Submission status: Wrong Answer

Solution code:
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
d=dict()
for i in map(int,input().split()):
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=1
for i in range(n-1,0,-2):
  if i not in d:
    ans=0
  else:
    if d[i]!=2:
      ans=0
if n%2>0:
  if 0 not in d:
    ans=0
  else:
    if d[0]!=1:
      ans=0
if ans:
  print(2**(n//2))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
mod = 10 ** 9 + 7
b = True
for i,j in enumerate(a):
  if n % 2:
    if j != ((i+1) // 2) * 2:
      b = False
      break
  else:
    if j != (i // 2) * 2 + 1:
      b = False
      break
if b == True:
  print(((n // 2) ** 2) % mod)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
mod = 10 ** 9 + 7
b = True
for i,j in enumerate(a):
  if n % 2:
    if j != ((i+1) // 2) * 2:
      b = False
      break
  else:
    if j != (i // 2) * 2 + 1:
      b = False
      break
print(((n // 2) ** 2) % mod) if b == True else print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = True
for i,j in enumerate(a):
  if n % 2:
    if j != ((i+1) // 2) * 2:
      b = False
      break
  else:
    if j != (i // 2) * 2 + 1:
      b = False
      break
print((n // 2) ** 2) if b == True else print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False


for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*(i//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print(((people_num//2) **2) % (10**9 +7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False


for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*(i//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False



for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False

for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

if(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False

for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

print(bool_false)
if(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
p=int(input())
a=[int(i) for i in input().split()]
diff=collections.Counter(a)
if p%2:#odd
    if all([diff[i]==2 for i in range(2,p,2)]) and diff[0]==1:
        ans=2**(p//2)
    else:ans=0
else:#even
    if all([diff[i]==2 for i in range(1,p+1,2)]):
        ans=2**(p//2)
    else:ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys

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

counts = defaultdict(int)
mod = N % 2

for a in A:
    if a % 2 == mod:
        print(0)
        sys.exit()
    counts[a] += 1
    if a == 0 and counts[a] > 1:
        print(0)
        sys.exit()
    if a > 0 and counts[a] > 2:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

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

A.sort()
B = [abs(a-b) for a,b in zip(range(N-1,-1,-1),range(N))]
B.sort()

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

Submission status: Wrong Answer

Solution code:
N=int(input())

mp=[0 for i in range(N)]
for a in input().split():
    mp[int(a)]+=1

res=True
if N%2==1:
    for i in range(2,N,2):
        if mp[i]!=2:
            res=False
    if mp[0]!=1:
        res=False
else:
    for i in range(1,N,2):
        if mp[i]!=2:
            res=False
if res:
    print(pow(2,N//2,10**7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
count = [0 for _ in range(N+1)]

if N % 2 == 0:
    if len(set(A)) != int(N/2):
        print(0)
        exit()
else:
    if len(set(A)) != int(N/2)+1:
        print(0)
        exit()

for i in A:
    count[i] += 1

res = 1
for i in range(N+1):
    if count[i] == 2:
        res *= 2
    else:
        if i != 0 and N%2 != 0:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
count = [0 for _ in range(N+1)]

if N % 2 == 0:
    if len(set(A)) != int(N/2):
        print(0)
        exit()
else:
    if len(set(A)) != int(N/2)+1:
        print(0)
        exit()

for i in A:
    count[i] += 1

res = 1
for i in range(N+1):
    if count[i] == 2:
        res *= 2
    else:
        if i != 0 and N%2 != 0:
            print(0)
            exit()

print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1 and a[0]==0:
    a.pop(0)
d=(0 if n%2==1 else 1)
for i in range(n//2):
    if a[2*i]!=2*(i+1)-d or a[2*i+1]!=2*(i+1)-d:
        print(0)
        break
else:
    print(2**(n//2))

Submission status: Wrong Answer

Solution code:
b = int(input())
x = list(map(int, input().split()))
x.sort()
f = 0
if b%2==0:
    for i in range(0,b,2):
        if not x[i]==x[i+1]==i+1: f =1
else:
    for i in range(0,b-2,2):
        if not x[i+1]==x[i+2]==i+2: f =1
    if not x[0]==0:f=1
if f:
    print(0)
else:
    print((b//2)**2)

Submission status: Wrong Answer

Solution code:
b = int(input())
x = list(map(int, input().split()))
f = 0
if b%2==0:
    for i in range(b//2):
        if not x.count(2*i+1): f =1
else:
    for i in range(b//2):
        if not x.count(2*i+2): f =1
    if x.count(0) != 1:f=1
if f:
    print(0)
else:
    print((b//2)**2)

Submission status: Wrong Answer

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

co = a_list.copy()
co.sort()
if 0 in co:
    co.remove(0)

if not len(co) % 2 == 0:
    print(0)
    quit()

else:
    print(0)
    quit()


for index in range(len(a_list)[:-1:2]):
    if not a_list[index] == a_list[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Wrong Answer

Solution code:

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

co = a_list.copy()
co.sort()
if 0 in co:
    co.remove(0)

if len(co) %2 == 0:
    print(0)
    quit()

else:
    print(0)
    quit()


for index in range(len(a_list)[:-1:2]):
    if not a_list[index] == a_list[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N % 2 == 1:
    l.append(0)
    N -= 1
else:
    l = list(map(lambda x: x-1, l))

l = sorted(l)
i = 0
for f, s in zip(l[0::2], l[1::2]):
    if f == 2*i and s == 2*i:
        i += 1
    else:
        print(0)
        exit()

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