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 collections

N = int(input())

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

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

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

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



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

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())

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

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

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

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



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

Submission status: Wrong Answer

Solution code:
n=int(input())
L=list(map(int,input().split()))
mod=10**9+7
if n==1:
    if L==[1]:
        print(1)
    else:
        print(0)
elif n%2==0:
    M=[2*i+1 for i in range(n//2)]
    M=M+M
    M.sort()
    L.sort()
    print((2**(n//2))%mod if L==M else 0)
else:
    M=[2*i for i in range(n//2 +1)]
    M=M+M[1:]
    M.sort()
    L.sort()
    print((2**(n//2))%mod if L==M else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
flag=0
if n%2==0:
    for i in range(n//2):
        if s.count(str(2*i+1))!=2:
            flag=1
else:
    if s.count(str(0))!=1:
        flag=1
    for i in range(1,n//2+1):
        if s.count(str(2*i))!=2:
            flag=1
print(2**(n//2) if flag==0 else 0)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

MOD = 10 ** 9 + 7

n, *a = map(int, sys.stdin.read().split())

def main():
    c = Counter(a)
    if n & 1:
        if c.get(0, 0) != 1:
            return 0
    for i in range(1 + n&1, n, 2):
        if c.get(i, 0) != 2:
            return 0

    return pow(2, n // 2, MOD)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

n, *a = map(int, sys.stdin.read().split())

def main():
    c = Counter(a)
    if n & 1:
        if c.get(0, 0) != 1:
            return 0
        for i in range(2, n, 2):
            if c.get(i, 0) != 2:
                return 0
    else:
        for i in range(1, n, 2):
            if c.get(i, 0) != 2:
                return 0

    return 2 ** (n // 2)
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
for i in range(n):
  if n%2==0:
    if i//2*2+1!=b[i]:
      print(0)
      exit()
  if n%2==1:
    if (i+1)//2*2!=b[i]:
      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 == 0:
  l_ = [0]*(n//2)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)):
    if l_[j] != 2:
      print(0)
      exit()
  else:
    print(2**(n//2))

else:
  l_ = [0]*(n//2+1)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)):
    if j != len(l_)-1: 
      if l_[j] != 2:
        print(0)
        exit()
    else:
      if l_[j] != 1:
        print(0)
        exit()
  else:
    print(2**(n//2))

Submission status: Wrong Answer

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

if n%2 == 0:
  l_ = [0]*(n//2)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)):
    if l_[j] != 2:
      print(0)
      exit()
  else:
    print(2**(n//2))

else:
  l_ = [0]*(n//2+1)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)-1):
    if l_[j] != 2:
      print(0)
      exit()
  else:
    print(2**(n//2))

Submission status: Wrong Answer

Solution code:
import sys
import math

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

A.sort()
#print(A)

s = 0 if N%2 else 1
e = N if N%2 else N+1

for i in range(s, e):
	t = math.ceil(i/2)*2
	if not N%2: t -= 1
	if t != A[i-s]:
		print(0)
		break
else:
	print(2**(N//2))

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0
counts = collections.Counter(a)
mod = 10**9+7
print(counts)

if n % 2 == 1:
    # if counts[0] is None or counts[0] != 1:
    if counts[0] != 1:
        print(0)
        sys.exit()
    for i in range(2, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(1, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()

ans = 2**(n//2)

print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0
counts = collections.Counter(a)
# print(counts)

if n % 2 == 1:
    if counts[0] != 1:
        print(0)
        sys.exit()
    for i in range(2, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(1, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()

ans = 2**(n//2)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0
counts = collections.Counter(a)
# print(counts)

if n % 2 == 1:
    if counts[0] != 1:
        print(0)
        sys.exit()
    for i in range(2, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(2, n-1, 2):
        if counts[i] != 2:
            print(0)
            sys.exit()

ans = 2**(n//2)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import sys
import collections

n = int(input())
a = list(map(int, input().split()))
ans = 0
counts = collections.Counter(a)

if n % 2 == 1:
    if counts[0] != 1:
        print(0)
        sys.exit()
    for i in range(2, n-1):
        if counts[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(2, n-1):
        if counts[i] != 2:
            print(0)
            sys.exit()

ans = 2**(n//2)

print(ans)

Submission status: Wrong Answer

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

if n%2==1:
  if a[0]!=0:
    print(0)
    exit(0)
  a=a[1:]
  for i in range(len(a)):
    a[i]=a[i]-1
    
for i in range(len(a)):
  if a[i]!=i+(i%2==0):
    print(0)
    exit(0)
    
print(2**(len(a)//2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
INF = 10 ** 9 + 7
N = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for key in a:
    d[key] += 1

sd = sorted(d.items(), key=lambda x: x[0])

if N % 2 == 0:
    if sd[0][1] == 1:
        print(0)
        exit()
else:
    if sd[0][1] != 1:
        print(0)
        exit()
ans = 1
for i in range(N // 2):
    ans *= 2

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
N = int(input())
A = list(map(int,input().split()))
A_count = Counter(A)
count_item = list(A_count.items())
count_item.sort()
start = 1 - (N % 2)
for i in range(math.ceil(N / 2)):
    if i == 0 and N % 2 == 1:
        if count_item[i][0] == 0 and count_item[i][1] != 1:
            print("0")
            exit()
    else:
        if count_item[i][0] != i * 2 + (1 - (N % 2)) or count_item[i][1] != 2:
            print("0")
            exit()
print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math
N = int(input())
A = list(map(int,input().split()))
A_count = Counter(A)
Acount_keys = list(A_count.keys())
Acount_keys.sort()
#print(A_count)
now = 0

for i in range(math.ceil(N / 2)):
    if Acount_keys[i] != i * 2 + (1 - N % 2):
        print("0")
        exit()
    elif i == 0 and Acount_keys[i] == 0:
        if A_count[0] != 1:
            print("0")
            exit()
    elif A_count[i *2 + (1 - N % 2)] != 2:
            print("0")
            exit()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
Alist = list(map(int, input().split()))
AC = Counter(Alist)
if N % 2 == 0:
    for num in range(1, N, 2):
        if AC[num] != 2:
            print(0)
            break
    else:
        print(2**(N // 2))
else:
    for num in range(2, N + 1, 2):
        if AC[0] != 1 or AC[num] != 2:
            print(0)
            break
    else:
        print(2**(N // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
Alist = list(map(int, input().split()))
AC = Counter(Alist)
if N % 2 == 0:
    for num in range(1, N, 2):
        if AC[num] != 2:
            print(0)
            break
    else:
        print(2**(N // 2))
else:
    for num in range(2, N, 2):
        if AC[0] != 1 or AC[num] != 2:
            print(0)
            break
    else:
        print(2**(N // 2))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

memo = {}
ans = 0

for a in A:
  v = str(a)
  if v in memo:
    memo[v] += 1
  else:
    memo[v] = 1

failed = False
for key in memo.keys():
  if key == '0':
    if N%2 == 0:
      failed=True
      break
    if memo[key] != 1:
      failed=True
      break
  elif memo[key] != 2:
    failed=True
    break
    
if not failed:
  x = len(memo.keys())
  if N%2 != 0:
    x-=1
  ans = 2**x
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10**9+7
res = 2**num
print(res%mod)

Submission status: Wrong Answer

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

    # for ai in A:
    #     x = (ai + N - 1) // 2
    #     y = N - x - 1
    #     print(x, y)

    C = [0] * N
    for ai in A:
        C[ai] += 1
    # print(C)

    flag = True
    if N % 2 == 1:
        for i, n in enumerate(C):
            # print(i, n)
            if i == 0:
                if n != 1:
                    flag = False
            elif i % 2 == 0:
                if n != 2:
                    flag = False
            else:  # 奇数の時
                if n != 0:
                    flag = False
        if not flag:
            ans = 0
        else:
            ans = ((N - 1)//2) ** 2
    else:
        for i, n in enumerate(C):
            if i % 2 == 1:
                if n != 2:
                    flag = False
            else:
                if n != 0:
                    flag = False
        if not flag:
            ans = 0
        else:
            ans = (N // 2) ** 2

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




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
judge=True
if n%2!=0:#奇数のとき
	if a[0]==0:
		for i in range(1,n//2+1):
			if a[i*2-1]!=i*2 or a[i*2]!=i*2:
				judge=False
				break
	else:
		judge=False
	if judge:
		ans=2**(n//2)
	else:
		ans=0

else:
	for i in range(n//2):
		if a[i*2]!=i*2+1 or a[i*2+1]!=i*2+1:
			judge=False
			break
	if judge:
		ans=2**(n//2)
	else:
		ans=0
		
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
#まずaの条件がありうるかを判定する。

def kaijo(n):
  temp=1
  for i in range(n):
    temp*=2
    temp%=mod
  return temp

#nが奇数の場合…
if n%2:
  ki=[0]*((n+1)//2)
  for i in a:
    if i==0: #0の場合は2個なので2を足す
      ki[0]+=2
    elif i%2==0: #ちゃんと偶数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(kaijo((n-1)//2))
  else:
    print(0)
else:
  ki=[0]*(n//2)
  for i in a:
    if i%2: #ちゃんと奇数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(2**kaijo((n//2)))
  else:
    print(0)

Submission status: Wrong Answer

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

#まずaの条件がありうるかを判定する。

#nが奇数の場合…
if n%2:
  ki=[0]*((n+1)//2)
  for i in a:
    if i==0: #0の場合は2個なので2を足す
      ki[0]+=2
    elif i%2==0: #ちゃんと偶数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(2**((n-1)//2))
  else:
    print(0)
else:
  ki=[0]*(n//2)
  for i in a:
    if i%2: #ちゃんと奇数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(2**(n//2))
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = Counter([int(i) for i in input().split()])

res = (n // 2) ** 2
res %= 10**9 + 7

if n % 2 == 1:
    if 0 not in a:
        res = 0
    elif a[0] != 1:
        res = 0
    for i in range(2, n, 2):
        if a[i] != 2:
            res = 0
else:
    for i in range(1, n, 2):
        if a[i] != 2:
            res = 0

print(res)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = Counter([int(i) for i in input().split()])

res = (n // 2) ** 2

if n % 2 == 1:
    if 0 not in a:
        res = 0
    elif a[0] != 1:
        res = 0
    for i in range(2, n, 2):
        if a[i] != 2:
            res = 0
else:
    for i in range(1, n, 2):
        if a[i] != 2:
            res = 0

print(res)

Submission status: Wrong Answer

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

if len(A) % 2 == 0:
    S = [x for x in range(len(A)-1, 0, -2)] * 2 
else:
    S = [x for x in range(len(A)-1, 1, -2)] * 2 + [0]

S = sorted(S)
if S == A and len(A) == 1:
    ans = 1
elif S == A and len(A) == 2:
    ans = 2
elif S == A:
    ans = ((len(A)//2)**2) % (10**9 + 7)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

if len(A) % 2 == 0:
    S = [x for x in range(len(A)-1, 0, -2)] * 2 
else:
    S = [x for x in range(len(A)-1, 1, -2)] * 2 + [0]

S = sorted(S)
if S == A and len(A) == 1:
    ans = 1
elif S == A and len(A) == 2:
    ans = 2
elif S == A:
    ans = ((len(A)//2)**2) & (10**9 + 7)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

def calculation(L):
    global check
    if len(L) % 2 == 0:
        if len(L) >= 4:
            X = [x for x in range(1,len(L),2)] * 2
            S = sorted(X)
            if L == S:
                pass
            else:
                check = 1
        else:
            S = [1,1]
            if L == S:
                pass
            else:
                check = 1
    if len(L) % 2 == 1:
        if len(L) >= 3:    
            X = [x for x in range(2, len(L), 2)] * 2 + [0]
            S = sorted(X)
            if L == S:
                pass
            else:
                check = 1
        else:
            S = [0]
            if L == S:
                pass
            else:
                check = 1
        
calculation(A)

if check == 1:
    ans = 0
elif len(A) == 1:
    ans = 1
elif len(A) == 2:
    ans = 2
else:
    ans = ((len(A)//2) ** 2) % ((10**9) + 7)
print(ans)

Submission status: Wrong Answer

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

def calculation(L):
    global check
    if len(L) % 2 == 0:
        if len(L) >= 4:
            X = [x for x in range(1,len(L),2)] * 2
            S = sorted(X)
            if A == S:
                pass
            else:
                check = 1
        else:
            S = [1,1]
            if L == S:
                pass
            else:
                check = 1
    if len(L) % 2 == 1:
        if len(L) >= 3:    
            X = [x for x in range(2, len(L), 2)] * 2 + [0]
            S = sorted(X)
            if L == S:
                pass
            else:
                check = 1
        else:
            S = [0]
            if L == S:
                pass
            else:
                check = 1
        
calculation(A)

if check == 1:
    ans = 0
elif len(A) == 1:
    ans = 1
elif len(A) == 2:
    ans = 2
else:
    ans = ((len(A)//2) ** 2) % (10**9 + 7)
print(ans)

Submission status: Wrong Answer

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

def calculation(L):
    global check
    if len(L) % 2 == 0:
        if len(L) >= 4:
            X = [x for x in range(1,len(L),2)] * 2
            S = sorted(X)
            if A == S:
                pass
            else:
                check = 1
        else:
            S = [1,1]
            if L == S:
                pass
            else:
                check = 1
    if len(L) % 2 == 1:
        if len(L) >= 3:    
            X = [x for x in range(2, len(L), 2)] * 2 + [0]
            S = sorted(X)
            if L == S:
                pass
            else:
                check = 1
        else:
            S = [0]
            if L == S:
                pass
            else:
                check = 1
        
calculation(A)

if check == 1:
    ans = 0
elif len(A) == 1:
    ans = 1
elif len(A) == 2:
    ans = 2
else:
    ans = (len(A)//2) ** 2
print(ans)

Submission status: Wrong Answer

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

def calculation(L):
    global check
    if len(L) % 2 == 0:
        X = [x for x in range(1,len(L),2)] * 2
        S = sorted(X)
        if A == S:
            pass
        else:
            check = 1
    if len(L) % 2 == 1:
        if len(L) >= 3:    
            X = [x for x in range(2, len(L), 2)] * 2 + [0]
            S = sorted(X)
            if L == S:
                pass
            else:
                check = 1
        else:
            S = [0]
            if L == S:
                pass
            else:
                check = 1
        
calculation(A)

if check == 1:
    ans = 0
elif len(A)==1:
    ans = 1
else:
    ans = (len(A)//2) ** 2
print(ans)

Submission status: Wrong Answer

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

check = 0

def calculation(L):
    global check
    if len(L) % 2 == 0:
        for i in range(1, len(L), 2):
            if L.count(i) == 2:
                pass
            else:
                check = 1
                break
    if len(L) % 2 == 1:
        for i in range(0, len(L), 2):
            if i == 0:
                if A.count(i) == 1:
                    pass
                else:
                    check = 1
                    break
            elif L.count(i) == 2:
                pass
            else:
                check = 1
                break
            
calculation(A)

if check == 1:
    ans = 0
else:
    ans = (len(A)//2) ** 2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#C
import math
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A.sort()
if N%2 == 0:
    n = N//2
    flag = 0
    for i in range(N):
        I = i//2 * 2 + 1
        if A[i] != I:
            flag = 1
            break
    if flag == 1:
        print(0)
    else:
        print(2**n)
    
else:
    n = N//2
    flag = 0
    for i in range(N):
        if i == 0:
            if A[0] != 0:
                flag = 1
                break
        else:
            I = (i+1)//2 * 2
            if A[i] != I:
                flag = 1
                break
    if flag == 1:
        print(0)
    else:
        print(2**n)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())
a=[int(i) for i in input().split()]
if(n%2==0):
    even=True
else:
    even=False
if(even==True and 0 in a):
    print(0)
    exit()

c = collections.Counter(a)
ans=1
for num,count in c.items():
    if(num==0 and count>=2):
        print(0)
        exit()
    elif(count>=3):
        print(0)
        exit()
    elif(num!=0):
        ans*=2
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
m=10**9+7
def g(A,n):
  return bisect.bisect_right(A,n)-bisect.bisect_left(A,n)
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  else:
    for j in range(1,N//2+1):
      if g(A,2*j-1)!=2:
        print(0)
        exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if g(A,2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=list(map(int,input().split()))
A.sort()
m=10**9+7
def g(n):
  return bisect.bisect_right(A,n)-bisect.bisect_left(A,n)
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  else:
    for j in range(1,N//2+1):
      if g(2*j-1)!=2:
        print(0)
        exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if g(2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=list(map(int,input().split()))
m=10**9+7
def g(n):
  return bisect.bisect_right(A,n)-bisect.bisect_left(A,n)
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  else:
    for j in range(1,N//2+1):
      if g(2*j-1)!=2:
        print(0)
        exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if g(2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
m=10**9+7
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  for j in range(1,N//2+1):
    if A.count(2*j-1)!=2:
      print(0)
      exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if A.count(2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=list(map(int,input().split()))
m=10**9+7
def g(n):
  return bisect.bisect_right(A,n)-bisect.bisect_left(A,n)
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  else:
    for j in range(1,N//2+1):
      if g(2*j-1)!=2:
        print(0)
        exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if g(2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
m=10**9+7
if N&2==0:
  if A.count(0)!=0:
    print(0)
    exit()
  else:
    for j in range(1,N//2+1):
      if A.count(2*j-1)!=2:
        print(0)
        exit()
else:
  if A.count(0)!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if A.count(2*i)!=2:
      print(0)
      exit()
print((2**(N//2))%m)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = list(map(int, input().split()))
counter = collections.Counter(A)
flag = True

if N % 2 != 0:
    for i in range(0, max(A) + 1):
        if i == 0:
            if counter[i] != 1:
                flag = False
                break
        elif (i % 2 == 0 and counter[i] != 2) or (i % 2 != 0 and counter[i] != 0):
            flag = False
            break                
    ans = 2 ** (max(A) // 2)

else:
    for i in range(0, max(A) + 1):
        if (i % 2 == 0 and counter[i] != 0) or (i % 2 != 0 and counter[i] != 2):
            flag = False
            break
    ans = 2 ** (max(A) // 2 + 1)

if flag:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = list(map(int, input().split()))
counter = collections.Counter(A)
flag = True
if N % 2 != 0:
    for num, count in counter.items():
        if num == 0:
            if count != 1:
                flag = False
                break            
        elif (num % 2 == 0 and count != 2) or (num % 2 != 0 and count != 0):
            flag = False
            break
else:
    for num, count in counter.items():
        if (num % 2 == 0 and count != 0) or (num % 2 != 0 and count != 2):
            flag = False
            break

if flag:
    print(2**round(max(A) / 2))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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 t == A:
	print((2**(N//2))%mod)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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 t == A:
	ans = 1
	for _ in range(N//2):
		ans *= 2
		ans %= mod
	print(ans)
#else:
#	print(0)

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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 t == A:
	ans = 1
	for _ in range(N//2):
		ans *= 2
		ans %= mod
	print(ans)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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 t == A:
	ans = 1
	for _ in range(N//2):
		ans = (ans * 2) % mod
	print(ans%mod)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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:
	ans = 1
	for _ in range(N//2):
		ans = (ans * 2) % mod
	print(ans%mod)
else:
	print(0)

#print(t)
#print(A)

Submission status: Wrong Answer

Solution code:
import sys
mod = 10**9 + 7
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))%mod)
else:
	print(0)

#print(t)
#print(A)