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:
from collections import Counter

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

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

Submission status: Wrong Answer

Solution code:
import math

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

A.sort()

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

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

Submission status: Wrong Answer

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

# error1: ペアができない場合。ただし、nが奇数のときは0が1個だけ。nが偶数のときは普通通り
from collections import defaultdict
flag = True
if n % 2 == 0:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 0:
      flag = False
    if v != 2:
      flag = False
else:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 1:
      flag = False
    if k == 0:
      if v != 1:
        flag = False
    elif v != 2:
      flag = False

ans = 2 ** (n //2)
print(ans)

Submission status: Wrong Answer

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

# error1: ペアができない場合。ただし、nが奇数のときは0が1個だけ。nが偶数のときは普通通り
from collections import defaultdict
flag = True
if n % 2 == 0:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 0:
      flag = False
    if v != 2:
      flag = False
else:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 1:
      flag = False
    if k == 0:
      if v != 1:
        flag = False
    elif v != 2:
      flag = False

ans = 2 ** (n //2)

print(0)

Submission status: Wrong Answer

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

# error1: ペアができない場合。ただし、nが奇数のときは0が1個だけ。nが偶数のときは普通通り
from collections import defaultdict
flag = True
if n % 2 == 0:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 0:
      flag = False
    if v != 2:
      flag = False
else:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k % 2 == 1:
      flag = False
    if k == 0:
      if v != 1:
        flag = False
    elif v != 2:
      flag = False

ans = 2 ** (n //2)
if flag:
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

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

# error1: ペアができない場合。ただし、nが奇数のときは0が1個だけ。nが偶数のときは普通通り
from collections import defaultdict
flag = True
if n % 2 == 0:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if v != 2:
      flag = False
else:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k == 0:
      if v != 1:
        flag = False
    elif v != 2:
      flag = False

ans = 2 ** (n //2)
if flag:
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

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

# error1: ペアができない場合。ただし、nが奇数のときは0が1個だけ。nが偶数のときは普通通り
from collections import defaultdict
flag = True
if n % 2 == 0:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if v != 2:
      flag = False
else:
  dic = defaultdict(int)
  for a in A:
    dic[a] += 1
  for k, v in dic.items():
    if k == 0 and v != 1:
      flag = False
    elif v != 2:
      flag = False

ans = 2 ** (n //2)
if flag:
  print(ans)
else:
  print(0)

Submission status: Wrong Answer

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

a.sort()


if n%2 == 1:
    b = [0]
    for i in range(1, (n-1)//2+1):
        b.append(i*2)
        b.append(i*2)
    if b == a:
        print(2**((n-1)//2))
    else:
        print(0)
else:
    b = []
    for i in range(n//2):
        b.append(1 + 2*i)
        b.append(1 + 2*i)
    if b == a:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N,A=ilint()
C=counter()
for a in A:
    C.add(a)
ans=2**(N//2)
for k in range((N-1)%2,N,2):
    if k not in C or C[k]!=2-(k==0):
        ans=0
        break
print(ans)

Submission status: Wrong Answer

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

seen = {}

for ai in a:
    if ai in seen:
        seen[ai] += 1
    else:
        seen[ai] = 1

ans = True
cur = 0
if n%2 == 1:
    if not (0 in seen and seen[0] == 1):
        ans = False
    else:
        cur = 2
else:
    cur = 1

if ans:
    for i in range(cur, n, 2):
        if not (i in seen and seen[i] == 2):
            ans = False
            break

print(2**(n//2) if ans else 0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
mod=pow(10,9)+7
sort_A=sorted(A)
numbers=[]
if N%2==0:
    for n in range(1,N,2):
        numbers+=[n]*2
    if sort_A==numbers:
        print(2**(N//2))
    else:
        print(0)
else:
    numbers.append(0)
    for n in range(2,N,2):
        numbers+=[n]*2
    if sort_A==numbers:
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    A = NLI()
    cA = collections.Counter(A)
    
    sortedA = sorted(list(cA.items()))
    
    if N % 2 == 1:
        if sortedA[0] != (0,1):
            print(-1)
            sys.exit()
        
        ans = 1
        for n in range(1,len(sortedA)):
            if sortedA[n] != (n*2 , 2):
                print(-1)
                sys.exit()
            ans = ans * 2 % MOD
                
        print(ans)
        
        
    else:
        ans = 1
        for n in range(len(sortedA)):
            if sortedA[n] != tuple([n*2+1 , 2]):
                print(-1)
                sys.exit()
            ans = ans * 2 % MOD
                
        print(ans)
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

def solver(N, A):
    cnt = Counter(A)
    x = 1
    if N%2 == 1:
        if cnt[0] != 1:
            return 0
        x = 2
    for i in range(x, N, 2):
        if cnt[i] != 2:
            return 0
    
    return 2**(N//2)

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

print(solver(N, A))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
A = sorted(map(int, input().split()))
mod = 10 ** 9 + 7
if (N == 1 and A[0] != 0):
    print(0)
    exit()

d = defaultdict(int)
for i in range(N):
    if (N % 2 == 0):
        if (A[0] != 1):
            print(0)
            exit()
        else:
            if (d[A[i]] == 0):
                d[A[i]] = 1
            elif (d[A[i]] == 1):
                d[A[i]] += 1

    else:
        if (A[0] != 0):
            print(0)
            exit()
        else:
            if (d[A[i]] == 0):
                d[A[i]] = 1
            elif (d[A[i]] == 1):
                d[A[i]] += 1

for i, v in d.items():
    if not (N % 2 == 1 and i == 0):
        if v != 2:
            print(0)
            exit()

dic = sorted(d)
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break
    if abs(dic[i] - dic[i + 1]) == 2:
        continue
    else:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7
if (N == 1 and A[0] != 0):
    print(0)
    exit()

d = defaultdict(int)
for i in range(N):
    if (d[A[i]] == 0):
        d[A[i]] = 1
    elif (d[A[i]] == 1):
        d[A[i]] += 1

for i, v in d.items():
    if (N % 2 == 0):
        if v == 2:
            print(0)
            exit()
    else:
        if i != 0 and v == 1:
            print(0)
            exit()
        elif i == 0 and v != 1:
            print(0)
            exit()

dic = sorted(d.items())
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break

    if dic[i][0] + 2 != dic[i + 1][0]:
        print(0)
        exit()

if (N % 2 == 0):
    if (dic[0][0] != 1):
        print(0)
        exit()
    print(2 ** (N // 2))
else:
    if (dic[0][0] != 0):
        print(0)
        exit()
    print(2 ** (N // 2))

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7
if (N == 1 and A[0] != 0):
    print(0)
    exit()

d = defaultdict(int)
for i in range(N):
    if (d[A[i]] == 0):
        d[A[i]] = 1
    elif (d[A[i]] == 1):
        d[A[i]] += 1

for i, v in d.items():
    if (N % 2 == 0):
        if v != 2:
            print(0)
            exit()
    else:
        if i != 0 and v == 1:
            print(0)
            exit()
        elif i == 0 and v != 1:
            print(0)
            exit()

dic = sorted(d.items())
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break

    if dic[i][0] + 2 != dic[i + 1][0]:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7
if (N == 1 and A[0] != 0):
    print(0)
    exit()

d = defaultdict(int)
for i in range(N):
    if (d[A[i]] == 0):
        d[A[i]] = 1
    elif (d[A[i]] == 1):
        d[A[i]] += 1

for i, v in d.items():
    if (N % 2 == 0):
        if i != 0 and v == 1:
            print(0)
            exit()
        elif i == 0 and v != 1:
            print(0)
            exit()

dic = sorted(d.items())
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break

    if dic[i][0] + 2 != dic[i + 1][0]:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

d = defaultdict(int)
for i in range(N):
    if (d[A[i]] == 0):
        d[A[i]] = 1
    elif (d[A[i]] == 1):
        d[A[i]] += 1
    else:
        print(0)
        exit()

for i, v in d.items():
    if (N % 2 == 0):
        if i != 0 and v == 1:
            print(0)
            exit()
        elif i == 0 and v != 1:
            print(0)
            exit()
    else:
        if v % 2 == 0:
            print(0)
            exit()


dic = sorted(d.items())
for i in range(len(dic)):
    if (i == len(dic) - 1):
        break

    if dic[i][0] + 2 != dic[i + 1][0]:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    A.sort()
    if N % 2 == 0:
        for i in range(0, N, 2):
            if A[i] == A[i + 1] == i + 1:
                continue
            else:
                print(0)
                sys.exit()
    else:
        for i in range(1, N, 2):
            if A[i] == A[i + 1] == i + 1:
                continue
            else:
                print(0)
                sys.exit()
        if A[0] != 0:
            print(0)
            sys.exit()
    print(pow(2, (N + 1) // 2, MOD))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

flag = True
if N % 2 == 0:
  for i in range(N):
    if A[i] != 1 + 2*(i//2):
      flag = False
      break
  if flag:
    ans = 2 ** (N//2)
  else:
    ans = 0
else:
  for i in range(N):
    if A[i] != 2*((i+1)//2):
      flag = False
      break
  if flag:
    ans = 2 ** (N//2)
  else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
As.sort()
mod = 10**9 + 7

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

Submission status: Wrong Answer

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

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

C = collections.Counter(A)
ret = 0
if N % 2 == 0:
    ret = 2**(N//2)
    for i in range(1, N, 2):
        if C[i] != 2:
            ret = 0
            break
else:
    ret = 2**(N//2)
    if C[0] != 1:
        ret = 0
    for i in range(2, N, 2):
        if C[i] != 2:
            ret = 0
            break

print(ret)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N = NI()
    A = sorted(NLI())
    if N % 2:
        for i in range(N):
            if i % 2 == 0 and A[i] == i:
                continue
            elif i % 2 == 1 and A[i] == i + 1:
                continue
            else:
                print(0)
                exit()
        print(2**(N//2))

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    if n % 2 == 0:
        num = 1
        for i in range(0, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print(0)
                exit()
            num += 2
    else:
        if A[0] != 0:
            print(0)
            exit()
        num = 2
        for i in range(1, n - 1, 2):
            if A[i] != num or A[i + 1] != num:
                print(0)
                exit()
            num += 2

    res = pow(2, n // 2)
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

from collections import Counter
cd = Counter(A)
# A.sort()

if N & 1:
    # odd
    if cd[0] != 1:
        print(0)
        exit(0)
    ng = False

    for ix in range(2, N//2 + 1, 2):
        if cd[ix] != 2:
            ng = True
            break

    if len(cd) != N//2 + 1:
        ng = True
    
    if ng:
        print(0)
    else:
        print(2**(N//2))

else:
    # even
    ng = False
    for ix in range(1, N//2+1, 2):
        if cd[ix] != 2:
            ng = True
            break
    
    if len(cd) != N//2:
        ng = True
    
    if ng:
        print(0)
    else:
        print(2**(N//2))

Submission status: Wrong Answer

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

from collections import Counter
cd = Counter(A)
# A.sort()

if N & 1:
    # odd
    if cd[0] != 1:
        print(0)
        exit(0)
    ng = False

    for ix in range(2, N//2 + 1, 2):
        if cd[ix] != 2:
            ng = True
            break

    if len(cd) != N//2 + 1:
        ng = True
    
    if ng:
        print(0)
    else:
        print(2**N//2)

else:
    # even
    ng = False
    for ix in range(1, N//2+1, 2):
        if cd[ix] != 2:
            ng = True
            break
    
    if len(cd) != N//2:
        ng = True
    
    if ng:
        print(0)
    else:
        print(2**N//2)

Submission status: Wrong Answer

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

b=[0 for _ in range(n)]
for i in range(n):
    b[a[i]]+=1

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

Submission status: Wrong Answer

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

b=[0 for _ in range(n)]
for i in range(n):
    b[a[i]]+=1
print(b)
c= 1 if n%2==0 else 0

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

Submission status: Wrong Answer

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

b=[0 for _ in range((n+1)//2)]
for i in range(n):
    b[a[i]//2]+=1
if n%2==0:
  for i in range(n//2):
    if b[i]!=2:
      print(0)
      break
  else:
    print(2**(n//2))
else:
  if b[0]!=1:
    print(0)
  else:
    for i in range(1,n//2+1):
      if b[i]!=2:
        print(0)
        break
    else:
      print(2**(n//2))

Submission status: Wrong Answer

Solution code:
# nの遇奇で出現する数字の数は固定されるのでそれから外れるとダメ 奇数んとき真ん中0以外ぜんぶ2 偶数ならぜんぶ2ずつ場所が割り当てられる
# もっとマシな実装できんのか
n = int(input())
a = list(map(int, input().split()))
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1
if n % 2 == 0:
    ans = 1
    for i in range(1, n, 2):
        if i not in d or d[i] != 2:
            print(0)
            exit()
        else:
            ans *= 2
    print(ans)
else:
    if 0 not in d or d[0] != 1:
        print(0)
        exit()
    ans = 1
    for i in range(2, n, 2):
        if i not in d or d[i] != 2:
            print(0)
            exit()
        else:
            ans *= 2
    print(ans)

Submission status: Wrong Answer

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = int(input())
data = list(map(int, input().split()))
cnt = count(data)

ans = 1
for k, v in cnt.items():
    if k == 0:
        if v > 1 or n %2 == 0:
            print(0)
            exit()
        continue
    else:
        if v <= 2:
            ans *= 2
        else:
            print(0)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = int(input())
data = list(map(int, input().split()))
cnt = count(data)

ans = 1
for k, v in cnt.items():
    if k == 0:
        if v > 1:
            print(0)
            exit()
        continue
    else:
        if v <= 2:
            ans *= 2
        else:
            print(0)
            exit()

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cA = Counter(A)
ans = pow(2,n//2)
for i in range(n//2+n%2):
    if i==0 and n%2==1:
        if cA[0] !=1:
            ans = 0
            break
    elif cA[2*i+1-n%2]!=2:
        ans = 0
        break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
cA = Counter(A)
if (n%2==1 and cA[0] != 1) or (n%2==0 and cA[1]!=2):
    print(0)
else:
    for i in range(1,n//2+n%2):
        if cA[2*i+1-n%2]!=2:
            print(0)
            break
        elif i==n//2+n%2-1:
            print(pow(2,n//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
if (n%2==1 and A.count(0) != 1) or (n%2==0 and A.count(1)!=2):
    print(0)
else:
    for i in range(1,n//2+n%2):
        if A.count(2*i+1-n%2)!=2:
            print(0)
            break
        elif i==n//2+n%2-1:
            print(pow(2,n//2))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

C = Counter(A)
if N % 2 == 0:
    if not all([i == 2 for i in C.values()]):
        print(0)
    else:
        print(2 ** len(C))
else:
    for i, v in C.items():
        if v > 2:
            print(0)
            exit()
        elif i != 0 and v == 1:
            print(0)
            exit()
        elif i == 0 and v > 1:
            print(0)
            exit()
    if 0 in C:
        print(2 ** (N // 2))
    else:
        print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
def powmod(a,n,m): #a^n mod m
    ans=1
    while n!=0:
        if n&1: ans*=a
        a**=2
        n>>=1
    return ans
n=int(input())
a=list(map(int,input().split()))
a.sort()
dic=Counter(a)
if n%2==0:
    temp={}
    for i in range(1,n,2):
        temp[i]=2
    if temp!=dict(dic):
        print(0)
        exit()
else:
    temp={}
    temp[0]=1
    for i in range(2,n,2):
        temp[i]=2
    if temp!=dict(dic):
        print(0)
        exit()
print(powmod(2,n//2,10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
def powmod(a,n,m): #a^n mod m
    ans=1
    while n!=0:
        if n&1: ans*=a
        a**=2
        n>>=1
    return ans
n=int(input())
a=list(map(int,input().split()))
a.sort()
dic=Counter(a)
if n%2==0:
    temp={}
    for i in range(1,n,2):
        temp[i]=2
    if temp!=dict(dic):
        print(0)
        exit()
else:
    temp={}
    temp[0]=1
    for i in range(0,n,2):
        temp[i]=2
    if temp!=dict(dic):
        print(0)
        exit()
print(powmod(2,n//2,10**9+7))

Submission status: Wrong Answer

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

if n==1:
  exit(print(0))
mod=10**9+7
a.sort()
t=0
ans=1
if n%2==0:
  t=1
  for i in range(n):
    if i==0 or i==1:
      if a[i]!=1:exit(print(0))
      continue
    if i%2==0:t+=2
    if a[i]!=t:exit(print(0))
  for i in range(n//2):
    ans*=2
    ans%=mod
else:
  for i in range(n):
    if i==0 and a[i]!=0:exit(print(0))
    if i%2==1:
      t+=2
    if a[i]!=t:exit(print(0))
  for i in range(n//2):
    ans*=2
    ans%=mod
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

mono = sorted(set(a))
dic = Counter(a)

if n % 2 == 1:
    last = 0
else:
    last = 1

res = 0
Cond = True
for x in mono:
    if x == 0 and a.count(0) == 1: last = 2
    elif x == last and dic[x] == 2:
        res += 1
        last += 2
    else: Cond = False

if Cond:
    print(2**res)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

mono = sorted(set(a))
dic = Counter(a)
ans = 1

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

if n % 2 == 1:
    if a.count(0) == 1:
        last = 0
        for x in mono:
            if x == 0: continue
            if last + 2 == x and dic[x] == 2:
                ans *= 2
                last = x
            else:
                ans *= 0
    else: ans *= 0

else:
    last = -1
    for x in mono:
        if last + 2 == x and dic[x] == 2:
            ans *= 2
            last = x
        else:
            ans *= 0
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

mono = sorted(set(a))
dic = Counter(a)
ans = 1

if n % 2 == 1:
    if a.count(0) == 1:
        last = 0
        for x in mono:
            if x == 0: continue
            if last + 2 == x and dic[x] == 2:
                ans *= 2
                last = x
            else:
                ans *= 0
    else: ans *= 0

else:
    last = -1
    for x in mono:
        if last + 2 == x and dic[x] == 2:
            ans *= 2
            last = x
        else:
            ans *= 0
print(ans)

Submission status: Wrong Answer

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

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

A.sort()

if A != chk:
    print(0)
else:
    print(pow(2, N // 2))

Submission status: Wrong Answer

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

from collections import Counter
cnt = Counter(a)
ans = 0
for i in range(n - 1, -1, -2):
    if cnt[i] == 2:
        ans += 1
        continue
    if i == 0 and cnt[i] == 1:
        break
    else:
        print(0)
        exit()
print(2 ** ans)

Submission status: Wrong Answer

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

import collections
c = collections.Counter(a)
m=0
for i in range(n//2):
    if n//2==n/2:
        if c[n-1-2*i]!=2:
            m=1
    else:
        if (i!=n//2-1 and c[n-1-2*i]!=2):
            m=1
        if (i==n//2 and c[n-1-2*i]!=1):
            m=1
if m==0:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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