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 = [int(i) for i in input().split()]
c = collections.Counter(a)
count = 0
point = 0
if n % 2 !=0:
    if c[0] == 1:
        for i in c.values():
            if i == 2:
                point += 1
                if point == n //2:
                    count += 2**(len(c.keys()) - 1)
else:
    for i in c.values():
        if i == 2:
            point += 1
            if point == n //2:
                count += 2**len(c.keys())
print(count)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = [int(i) for i in input().split()]
c = collections.Counter(a)
count = 0
point = 0
if n % 2 !=0:
    if c[0] == 1:
        count += 2**(len(c.keys()) - 1)
else:
    for i in c.values():
        if i == 2:
            point += 1
            if point == n //2:
                count += 2**len(c.keys())
print(count)

Submission status: Wrong Answer

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

from collections import Counter
MOD = 10 ** 9 + 7
c = Counter(a)

ans = 0

if n % 2 == 1:
    for i in range(2, n, 2):
        if c[i] != 2:
            break
    if c[0] == 1:
        ans = pow(2, n // 2, MOD)
else:
    for i in range(1, n, 2):
        if c[i] != 2:
            break
    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
MOD = 10 ** 9 + 7
c = Counter(a)

ans = 0

if n & 1:
    for i in range(2, n, 2):
        if c[i] != 2:
            break
    if c[0] == 1:
        ans = pow(2, n // 2, MOD)
else:
    for i in range(1, n, 2):
        if c[i] != 2:
            break
    ans = pow(2, n // 2, MOD)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

corrct = []
t = N - 1
for i in range(N):
    corrct.append(t)
    if i % 2 == 1:
        t -= 2

if all(corrct[i] == A[i] for i in range(N)):
    print(pow(2, N//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

def calc():
    c = Counter(A)
    if N % 2 == 0:
        for i, v in c.items():
            if i % 2 == 0:
                return 0
            if v != 2:
                return 0
    else:
        for i, v in c.items():
            if i % 2 == 1:
                return 0
            if i == 0 and v == 1:
                continue
            if v != 2:
                return 0
    return pow(2, N//2)

print(calc())

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int,input().split())), dtype=np.int32)
a = np.sort(a)
b = np.diff(a)
c = np.array([2,0]*(N//2), dtype=np.int32)
if N%2==0:
    c = np.array([0] + [2,0]*((N-1)//2), dtype=np.int32)
if (b==c).all():
    res = pow(2, (N-1)//2, 10**9+7) * ((N+1)%2+1)
    print(res)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
"""
奇数の場合は0が一つと偶数番号が2個ずつ存在している
偶数の場合は奇数番号が2個ずつ並んでいる
それらの条件を満たす場合に、並び替えることが可能で、
"""

N = int(input())
L = list(map(int, input().split()))
number_dict = {}

for l in L:
  if l in number_dict:
    number_dict[l] += 1
  else:
    number_dict[l] = 1

if N%2 ==1:
  if 0 in number_dict and number_dict[0] != 1:
    print(0)
    sys.exit()
  number_dict.pop(0)
  ran = range(2, N, 2)
else:
  ran = range(1, N, 2)

# チェック
for i in ran:
  if i not in number_dict:
    print(0)
    sys.exit()
  if number_dict[i] != 2:
    print(0)
    sys.exit()
  number_dict.pop(i)


if len(number_dict.keys()) == 0:
  print(2**int(N/2))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

mod = 10**9 + 7
n = int(input())
a = deque(sorted(list(map(int, (input().split())))))
if n % 2 == 0:
    for i in range(n//2):
        b = a.popleft()
        c = a.popleft()
        if b != (i+1)*2 or c != (i+1)*2:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

if n % 2 == 1:
    if a.popleft() != 0:
        print(0)
        sys.exit()
    for i in range(n//2):
        b = a.popleft()
        c = a.popleft()
        if b != (i+1)*2 or c != (i+1)*2:
            print(0)
            sys.exit()
    print(pow(2, n//2, mod))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
l = [abs(N - (n * 2 + 1)) for n in range(N)]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
l = [abs(N - (n * 2 + 1)) for n in range(N)]

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = map(int, input().split())
l = [v % 2 for v in Counter(A).values()]

c = l.count(0)
print(c ** 2 % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = map(int, input().split())
l = [v % 2 for v in Counter(A).values()]

if (sum(l) > 0 and N % 2 == 1) or (N % 2 == 0):
    c = l.count(0)
    print(c ** 2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
count=0
ans=1
A.sort()
if(N%2==0):
  flag=True
  for i in range(N):
    if(i%2==0):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        ans=(ans*2)%(10**9+7)
else:
  flag=True
  if(A[0]!=0):
    flag=False
  for i in range(N):
    if(i%2==1):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        ans=(ans*2)%(10**9+7)
if(flag==True):
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

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

for i in range(n):
   if a.count(0)>=2 or a.count(i)>=3:
       print(0)
       exit(0)
if max(a)>(n-1):
    print(0)
    exit(0)

if n%2==1:
    if all(i%2==0 for i in a):
        print(1 if numbers==1 else (len(numbers)-1)**2%(10**9+7))
    else:
        print(0)
else:
    if all(i%2==1 for i in a):
        print((len(numbers))**2%(10**9+7))
    else:
        print(0)

Submission status: Wrong Answer

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

for i in range(n):
   if a.count(0)>=2 or a.count(i)>=3:
       print(0)
       exit(0)
if max(a)>(n-1):
    print(0)
    exit(0)

if n%2==1:
    if all(i%2==0 for i in a):
        print(0 if numbers==1 else (len(numbers)-1)**2%(10**9+7))
    else:
        print(0)
else:
    if all(i%2==1 for i in a):
        print((len(numbers))**2%(10**9+7))
    else:
        print(0)

Submission status: Wrong Answer

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

for i in range(n):
   if a.count(0)>=2 or a.count(i)>=3:
       print(0)
       exit(0)
#if max(a)>(n-1):
    #print(0)
    #exit(0)

if n%2==1:
    if all(i%2!=0 for i in a):
        print(0)
    else:
        print((len(numbers)-1)**2%(10**9+7))
else:
    if all(i%2!=1 for i in a):
        print(0)
    else:
        print((len(numbers))**2%(10**9+7))

Submission status: Wrong Answer

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

for i in range(n):
   if a.count(0)>=2 or a.count(i)>=3:
       print(0)
       exit(0)
if max(a)>(n-1):
    print(0)
    exit(0)

if n%2==1:
    if all(i%2!=0 for i in a):
        print(0)
    else:
        print((len(numbers)-1)**2%(10**9+7))
else:
    if all(i%2!=1 for i in a):
        print(0)
    else:
        print((len(numbers))**2%(10**9+7))

Submission status: Wrong Answer

Solution code:
import collections

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

if a.count(0)>=2 or a.count(collections.Counter(a).most_common()[0][0])>=3:
    print(0)
    exit(0)
elif max(a)>(n-1):
    print(0)
    exit(0)
elif n%2==1 and all(i%2!=0 for i in a):
    print(0)
    exit(0)
elif n%2==0 and all(i%2!=1 for i in a):
    print(0)
    exit(0)

if a.count(0)==1:
    print((len(numbers)-1)**2%(10**9+7))
else:
    print((len(numbers))**2%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n=int(input())
a=list(map(int,input().split()))
lst=[0]*n
for i in range(n):
    lst[a[i]]+=1

for i in range(n):
    if n%2==0:
        if i%2==0 and lst[i]!=0:
            break
        elif i%2==1 and lst[i]!=2:
            break
    else:
        if i%2==1 and lst[i]!=0:
            break
        elif i%2==0:
            if i==0:
                if lst[i]!=1:
                    break
            elif lst[i]!=2:
                break
else:
    print(2**(n//2))
    exit()
print(0)

Submission status: Wrong Answer

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

for i in range(n):
    if a.count(0)>=2 or a.count(i)>=3:
        print(0)
        exit(0)
if max(a)>(n-1):
    print(0)
    exit(0)
if n%2==1 and all(i%2!=0 for i in a):
    print(0)
    exit(0)
elif n%2==0 and all(i%2!=1 for i in a):
    print(0)
    exit(0)

if a.count(0)==1:
    print((len(numbers)-1)**2%(10**9+7))
else:
    print((len(numbers))**2%(10**9+7))

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 v != 2:
        if N % 2 == 1 and k == 0:
            continue
        else:
            print("0")
            break
else:
    print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
d = N // 2
# ans = []
# def linking_up():
ans_1 = [ i for i in range(N) if i % 2 == 1 and i!= 0 and A.count(i) == 2]
    # for i in range(N):
        # if i % 2 == 0 and i != 0:
            # if A.count(i) == 2 and A.count(0) == 1:
                # ans.append('c')
ans_2 = [ i for i in range(N) if i % 2 == 0 and A.count(i) == 2]
        # else:
            # if A.count(i) == 2:
                # ans.append('a')
# linking_up()
if len(ans_1) == d:
    a = (2 ** d) % (10 ** 9 + 7)
    print(a)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
d = N // 2
# ans = []
# def linking_up():
ans_1 = [ i for i in range(N) if A.count(i) == 2]
    # for i in range(N):
        # if i % 2 == 0 and i != 0:
            # if A.count(i) == 2 and A.count(0) == 1:
                # ans.append('c')
# ans_2 = [ i for i in range(N) if i % 2 and A.count(i) == 2]
        # else:
            # if A.count(i) == 2:
                # ans.append('a')
# linking_up()
if len(ans_1) == d:
    print(2 ** d)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
mod=10**9+7
if N%2==0:
    for k in range(N//2):
        if A[2*k]==2*k+1 and A[2*k+1]==2*k+1:
            ans=ans*2%mod
            continue
        else:
            ans=0
            break
if N%2==1:
    if A[0]==0:
        ans=2
        for k in range(N//2-1):
            if A[2*k+2]==2*k+2 and A[2*k+1]==2*k+2:
                ans=ans*2%mod
                continue
            else:
                ans=0
                break
    else:
        ans=0
if N==1:
    if A[0]==1:
        ans=1
    else:
        ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
mod=10**9+7
if N%2==0:
    for k in range(N//2):
        if A[2*k]==2*k+1 and A[2*k+1]==2*k+1:
            ans=ans*2%mod
            continue
        else:
            ans=0
            break
if N%2==1:
    if A[0]==0:
        ans=2
        for k in range(N//2-1):
            if A[2*k+2]==2*k+2 and A[2*k+1]==2*k+2:
                ans=ans*2%mod
                continue
            else:
                ans=0
                break
    else:
        ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
comb = 0
c = Counter(a)
if n%2==0:
    i = 1 
else:
    if c[0]!=1:
        print(0)
        exit()
    c.pop(0)
    i = 2

for k in sorted(c):
    if i==k and c[k]==2:
        i+=2
        comb += 1
    else:
        print(0)
        exit()

print(2**comb)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
i = 0
if n%2==0:i=1
for k in sorted(c):
    if k==i==0:
        if c[k]==1:
            i+=2
        else:
            print(0)
            exit()
    elif k==i and c[k]==2:
        i+=2
    else:
        print(0)
        exit()

print(2**((i-1)//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = Counter(map(int, input().split()))
MOD = 10 ** 9 + 7

if N % 2:
    if A == Counter((i + 1) // 2 * 2 for i in range(N)):
        print(((N - 1) // 2) ** 2 % MOD)
    else:
        print(0)
else:
    if A == Counter(i // 2 * 2 + 1 for i in range(N)):
        print((N // 2) ** 2 % MOD)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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


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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=sorted(map(int,input().split()))[::-1]
def f(x):
  t=n+1
  for i in l[x::2]:
    if t-2!=i: return 0
    t=i
  return 1
print(2**(n//2)*f(0)*f(1))

Submission status: Wrong Answer

Solution code:
import math
n=input()
mod = int(1e9) + 7
a=list(map(int,raw_input().split()))
if(len(a)%2==0 and a.count(0)>0):
    print(0)
elif(len(a)%2!=0 and a.count(0)>1):
    print(0)
else:    
    res=0
    b=set(a)
    if(a.count(0)):
        print(pow(2,len(b)-1,mod))
    else:
        print(pow(2,len(b),mod))

Submission status: Wrong Answer

Solution code:
import math
n=input()
a=list(map(int,raw_input().split()))
if(len(a)%2==0 and a.count(0)>0):
    print(0)
elif(len(a)%2!=0 and a.count(0)>1):
    print(0)
else:    
    res=0
    b=set(a)
    if(a.count(0)):
        print(pow(2,len(b)-1))
    else:
        print(pow(2,len(b)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# C - Lining Up
# モジュールのインポート
import sys

# 標準入力の取得
N = int(input())
A_list = list(map(int, input().split()))

# 報告の正誤判定
sorted_A_list = sorted(A_list)
EXPECTED_LIST = []
is_N_even = (N % 2 == 0)
for n in range(N):
    is_n_even = (n % 2 == 0)
    if is_N_even:
        # Nが偶数の場合、[1, 1, 3, 3, ・・・, N-1, N-1]となる
        if is_n_even:
            EXPECTED_LIST.append(n+1)
        else:
            EXPECTED_LIST.append(n)
    else:
        # Nが奇数の場合、[0, 2, 2, 4, 4, ・・・, N-1, N-1]となる
        if is_n_even:
            EXPECTED_LIST.append(n)
        else:
            EXPECTED_LIST.append(n+1)

# 報告が誤りであった場合、0を出力して、処理を終了する
if sorted_A_list != EXPECTED_LIST:
    print(0)
    sys.exit()

# 報告が正しかった場合、並び方の総数を10^9+7で割った余りを出力
print(2**(N//2))

Submission status: Wrong Answer

Solution code:
import sys
"""
奇数の場合は0が一つと偶数番号が2個ずつ存在している
偶数の場合は奇数番号が2個ずつ並んでいる
それらの条件を満たす場合に、並び替えることが可能で、
"""

N = int(input())
L = list(map(int, input().split()))
number_dict = {}

for l in L:
  if l in number_dict:
    number_dict[l] += 1
  else:
    number_dict[l] = 1

if N%2 ==1:
  if number_dict[0] != 1:
    print(0)
    sys.exit()
  number_dict.pop(0)
  ran = range(2, N, 2)
else:
  ran = range(1, N, 2)

# チェック
for i in ran:
  if i not in number_dict:
    print(0)
    sys.exit()
  if number_dict[i] != 2:
    print(0)
    sys.exit()
  number_dict.pop(i)


if len(number_dict.keys()) == 0:
  print(2**int(N/2))
else:
  print(0)

Submission status: Wrong Answer

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

if n%2==0:
    for i in a:
        if i%2==0:
            print(0)
            exit()
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

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

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

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

Submission status: Wrong Answer

Solution code:
i=input
n=int(i())
print([0,2**(n//2)][sorted(i().split(),key=int)==[str((j+n%2)//2*2+1-n%2)for j in range(n)]])

Submission status: Wrong Answer

Solution code:
i=input
n=int(i())
print([0,2**(n//2)][sorted(i().split(),key=int)==[str((j+n%2)//2*2)for j in range(n)]])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n == 1 and l ==[0, 0]:
    print(1)
    exit()
else:
    a = []
    for i in range(1, n):
        if n % 2 == 1: # odd
            if i < n and i % 2 == 0:
                a += [i] * 2
        else:
            if i < n and i % 2 == 1:
                a += [i] * 2
    else:
        if n % 2 == 1:
            a.insert(0, 0)
    
if l != a:
    print(0)
else:
    print(2 ** (n // 2))

Submission status: Wrong Answer

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

if n == 1 and l ==[0, 0]:
    print(1)
else:
    a = []
    for i in range(1, n):
        if n % 2 == 1: # odd
            if i < n and i % 2 == 0:
                a += [i] * 2
        else:
            if i < n and i % 2 == 1:
                a += [i] * 2
    else:
        if n % 2 == 1:
            a.insert(0, 0)
    
if l != a:
    print(0)
else:
    print(2 ** (n // 2))

Submission status: Wrong Answer

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

if n == 1 and l ==[0, 0]:
    print(1)
else:
    a = []
    for i in range(1, n):
        if n % 2 == 1: # odd
            if i < n and i % 2 == 0:
                a += [i] * 2
        else:
            if i < n and i % 2 == 1:
                a += [i] * 2
    else:
        if n % 2 == 1:
            a.insert(0, 0)
    
if l != a:
    print(0)
else:
    print(2 ** (n // 2))

Submission status: Wrong Answer

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

a = []
for i in range(1, n):
    if n % 2 == 1: # odd
        if i < n and i % 2 == 0:
            a += [i] * 2
    else:
        if i < n and i % 2 == 1:
            a += [i] * 2
else:
    if n % 2 == 1:
        a.insert(0, 0)

if l != a:
    print(0)
else:
    print(2 ** (n // 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
a=0
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            return pow(2,(N-1)//2)
        else:
            return 0
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            return 0
        elif C[i]==0:
            continue
    return pow(2,(N-1)//2)
a=line(A,N)
print(a%(pow(10,9)+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
a=0
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            return pow(2,(N-1)//2)
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            return 0
        elif C[i]==0:
            continue
    return pow(2,(N-1)//2)
a=line(A,N)
print(a%(pow(10,9)+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
C = [0]*N
def line(A,N):
    for i in range(N):
        C[A[i]] += 1
    if C[0] == 1:
        if N % 2==1:
            print(pow(2,(N-1)//2))
            return
    for i in range(N):
        if C[i] != 2 and C[i]>=1:
            print(0)
            return
        elif C[i]==0:
            continue
    print(pow(2,(N-1)//2))
    return
line(A,N)

Submission status: Wrong Answer

Solution code:
n=int(input())
c=list(map(int,input().split()))
if n%2==0 and 0 in c:
	print(0)
elif n%2==1 and c.count(0)>=2:
	print(0)
else:
	print(pow(2,n//2))

Submission status: Wrong Answer

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

if N%2 ==1:
 for i in range(2,N,2):
  if A.count(i) == 2 and A[i]%2 == 0:
   List.append(1)
  else:
   List.append(0)
 if List.count(0) == 0:
  print(((N-1)//2)**2)
 else:
  print('False')

if N%2 ==0:
 for i in range(1,N,2):
  if A.count(i) == 2 and A[i]%2 == 1:
   List.append(1)
  else:
   List.append(0)
 if List.count(0) == 0:
  print((N//2)**2)
 else:
  print('False')

Submission status: Wrong Answer

Solution code:
import collections

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

m = collections.Counter(a)

# n: odd  ->  0, 2, ..., n-1
# n: even ->  1, 3, ..., n-1

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


for i in m:
    if i not in mm or m[i] != mm[i]:
        print(0)
        exit()

for i in mm:
    if i not in m or mm[i] != mm[i]:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
import collections

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

m = collections.Counter(a)

# n: odd  ->  0, 2, ..., n-1
# n: even ->  1, 3, ..., n-1

if n % 2 == 0:
    for ai in a:
        if ai % 2 == 0 or ai < 1 or ai > n - 1:
            print(0)
            exit()
        elif m[ai] != 2:
            print(0)
            exit()
else:
    for ai in a:
        if ai % 2 == 1 or ai < 0 or ai > n-1:
            print(0)
            exit()
        elif ai == 0 and m[0] != 1:
            print(0)
            exit()
        elif ai != 0 and m[ai] != 2:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
import collections

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

m = collections.Counter(a)

# n: odd  ->  0, 2, ..., n-1
# n: even ->  1, 3, ..., n-1

if n % 2 == 0:
    for ai in a:
        if ai % 2 == 0 or ai < 1 or ai > n - 1:
            print(0)
            exit()
        elif m[ai] != 2:
            print(0)
            exit()
else:
    for ai in a:
        if ai % 2 == 1 or ai < 1 or ai > n-1:
            print(0)
            exit()
        elif ai == 0 and m[0] != 1:
            print(0)
            exit()
        elif ai != 0 and m[ai] != 2:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
import collections

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

m = collections.Counter(a)

# n: odd  ->  0, 2, ..., n-1
# n: even ->  1, 3, ..., n-1

if n % 2 == 0:
    for ai in a:
        if ai % 2 == 0 or m[ai] != 2:
            print(0)
            exit()
else:
    for ai in a:
        if ai % 2 == 1:
            print(0)
            exit()
        elif ai == 0 and m[0] != 1:
            print(0)
            exit()
        elif ai != 0 and m[ai] != 2:
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 20:16
N = INT()
A = LIST()

dic = {}
for i in range(N):
    if not A[i] in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1

if N % 2 == 0:
    # even
    # N = 8
    for i in range(N//2):
        #4 (0, 1, 2, 3)
        if N - 1 - 2 * i not in dic:
            # 7, 5, 3, 1
            # なければでる
            print(0)
            exit()
        elif dic[N-1-2*i] != 2:
            print(0)
            break
        else:
            pass
    else:
        print(2 ** (N // 2))
else:
    if A.count(0) != 1:
        print(0)
        exit()
    else:
        # N = 5
        for i in range(N//2-1):
            # 2, (0, 1)
            if N - 1 - 2 * i not in dic:
                print(0)
                break
            elif dic[N-1-2*i] != 2:
                print(0)
                break
            else:
                pass
        else:
            print(2 ** (N // 2))



exit()


flag = True
if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if A.count(i) != 1:
                flag = False
        elif A.count(i * 2) != 2:
            flag = False
    if flag == False:
        print(0)
        exit()
    else:
        print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if A.count(2 * i + 1) != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 20:16
N = INT()
A = LIST()

dic = {}
for i in range(N):
    if not A[i] in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1

if N % 2 == 0:
    # even
    # N = 8
    for i in range(N//2):
        #4 (0, 1, 2, 3)
        if N - 1 - 2 * i not in dic:
            # 7, 5, 3, 1
            # なければでる
            print(0)
            exit()
        elif dic[N-1-2*i] != 2:
            print(0)
            break
        else:
            pass
    else:
        print(2 ** (N // 2))
else:
    if A.count(0) != 1:
        print(0)
        exit()
    else:
        # N = 5
        for i in range(N//2):
            # 2, (0, 1)
            if N - 1 - 2 * i not in dic:
                print(0)
                break
            elif dic[N-1-2*i] != 2:
                print(0)
                break
            else:
                pass
        else:
            print(2 ** (N // 2))



exit()


flag = True
if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if A.count(i) != 1:
                flag = False
        elif A.count(i * 2) != 2:
            flag = False
    if flag == False:
        print(0)
        exit()
    else:
        print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if A.count(2 * i + 1) != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
MOD = 10 * 9 + 7

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

if n % 2 == 1:
    l = (n + 1) * (n - 1)
else:
    l = n ** 2

if sum(a) == l // 2:
    print(2 ** (n//2) % MOD)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
MOD = 10 * 9 + 7

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

if n % 2 == 1:
    for i in range(n):
        if i % 2 == 1 and a[i] - 1 == i: continue
        elif i % 2 == 0 and a[i] == i: continue
        else: 
            print(0)
            exit()
else:
    for i in range(n):
        if i % 2 == 1 and a[i] == i: continue
        elif i % 2 == 0 and a[i] - 1 == i: continue
        else: 
            print(0)
            exit()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
MOD = 10 * 9 + 7

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

if n % 2 == 1:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(1, n):
        if i % 2 == 1 and a[i] - 1 == i: continue
        elif i % 2 == 0 and a[i] == i: continue
        else: 
            print(0)
            exit()
else:
    for i in range(1, n):
        if i % 2 == 1 and a[i] == i: continue
        elif i % 2 == 0 and a[i] - 1 == i: continue
        else: 
            print(0)
            exit()

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