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:
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+1) // 2 * 2 != a[i]:
            print(0)
            exit()
else:
    for i in range(n):
        if (i+2) // 2 * 2 -1 != a[i]:
            print(0)
            exit()

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

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()

flag = True
# A.sort()

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


if N % 2 == 1:
    for i in range(N):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif i % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
        # elif dic[i * 2] != 2:
        #     flag = False
    if flag == False:
        print(0)
    else:
        if N == 1:
            print(1)
        else:
            print(2 ** ((N) // 2))

else:
    for i in range(N):
        if (i - 1) % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))






        


    # c = Counter(A)
    # c = sorted(c.items(), key=lambda x: x[0], reverse = False)
    # if c[0][1] != 1:
        # print(0)
    # for i in c[1:]:
        # if c[0]

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()

flag = True
# A.sort()

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


if N % 2 == 1:
    for i in range(N):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif i % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
        # elif dic[i * 2] != 2:
        #     flag = False
    if flag == False:
        print(0)
    else:
        if N == 1:
            print(1)
        else:
            print(2 ** ((N-1) // 2))

else:
    for i in range(N):
        if (i - 1) % 2 == 0:
            if dic[i] != 2:
                flag = False
        else:
            if dic[i] != 0:
                flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))






        


    # c = Counter(A)
    # c = sorted(c.items(), key=lambda x: x[0], reverse = False)
    # if c[0][1] != 1:
        # print(0)
    # for i in c[1:]:
        # if c[0]

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()

flag = True
# A.sort()

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


if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif dic[i * 2] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        if N == 1:
            print(1)
        else:
            print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if dic[2 * i + 1] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))






        


    # c = Counter(A)
    # c = sorted(c.items(), key=lambda x: x[0], reverse = False)
    # if c[0][1] != 1:
        # print(0)
    # for i in c[1:]:
        # if c[0]

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()

flag = True
# A.sort()

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


if N % 2 == 1:
    for i in range((N+1) // 2):
        if i == 0:
            if dic[i] != 1:
                flag = False
        elif dic[i * 2] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** ((N-1) // 2))
else:
    for i in range(N // 2):
        if dic[2 * i + 1] != 2:
            flag = False
    if flag == False:
        print(0)
    else:
        print(2 ** (N//2))






        


    # c = Counter(A)
    # c = sorted(c.items(), key=lambda x: x[0], reverse = False)
    # if c[0][1] != 1:
        # print(0)
    # for i in c[1:]:
        # if c[0]

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    S = list(map(int, input().split()))
    if n % 2 == 0:
        sum_a = (1 + max(S)) * (n // 2)
    else:
        sum_a = (2 + max(S)) * (n // 2)
    if sum(S) == sum_a:
        ans = pow(2, n // 2)
    else:
        ans = 0

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    S = list(map(int, input().split()))
    ans = 0

    if n % 2 == 1 and S.count(0) != 1:
        ans = 0
    else:
        ans = pow(2, n // 2)

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5+1)
for i in range(n):
    b[a[i]]+=1
if n%2==0 and a.count(0)!=0:
    print(0)
    exit()
f=1
for i in range(n-1,-1,-2):
    if i==0:
        if b[i]!=1:
            f=0
            break
    elif b[i]!=2:
        f=0
        break
if f: 
    print(2**(n//2))
else: 
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5)
for i in range(n):
    b[a[i]]+=1
if n%2==0 and a.count(0)!=0:
    print(0)
    exit()
f=1
for i in range(n-1,-1,-2):
    if i==0:
        if b[i]!=1:
            f=0
            break
    elif b[i]!=2:
        f=0
        break
if f: 
    print(2**(n//2))
else: 
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

div = 10**9 + 7

def Mod_Pow(a,n,mod):
    res = 1
    while (n > 0):
        if (n & 1):
            res = (res * a )% mod
        a = (a * a)% mod
        n >>= 1
    
    return res

N = int(input())

A = list([int(i) for i in input().split()])

if N%2 == 0:
    ans = Mod_Pow(2,int(N/2),div)
    for i in range(int(N/2)):
        j = int(2*i+1)
        if A.count(j) != 2:
            ans = -1
            break
            
else:
    ans = Mod_Pow(2,int((N-1)/2),div)
    for i in range(int((N+1)/2)):
        j = int(2*i)
        if j==0:
            if A.count(j) != 1:
                ans = -1
            break
        elif A.count(j) != 2:
            ans = -1
            break
    
            
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = list(map(int,input().split()))
A = list(set(A))
c = 0
for i in range((N+1)%2, N, 2):
  if not A[c] == i:
    print(0)
    exit()
  c += 1
print(2**(c-c%2))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N==1:
    print(0)
else:
    if N % 2 == 0:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10**9+7))
        else:
            print(0)
    else:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list + [0]
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10**9+7))
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N==1:
    if A==0:
        print(1)
    else:
        print(0)
else:
    if N % 2 == 0:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10**9+7))
        else:
            print(0)
    else:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list + [0]
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10**9+7))
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N==1:
    if A==0:
        print(1)
    else:
        print(0)
else:
    if N % 2 == 0:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10**9+7))
        else:
            print(0)
    else:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list + [0]
        nlist.sort()
        if numbers == nlist:
            print((2 ** kazu)%(10*9+7))
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N==1:
    if A==0:
        print(1)
    else:
        print(0)
else:
    if N % 2 == 0:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list
        nlist.sort()
        if numbers == nlist:
            print(2 ** kazu)
        else:
            print(0)
    else:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list + [0]
        nlist.sort()
        if numbers == nlist:
            print(2 ** kazu)
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N==1:
    print(1)
else:
    if N % 2 == 0:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list
        nlist.sort()
        if numbers == nlist:
            print(2 ** kazu)
        else:
            print(0)
    else:
        for c in range(kazu):
            list.append(n - c * 2)
        nlist = list + list + [0]
        nlist.sort()
        if numbers == nlist:
            print(2 ** kazu)
        else:
            print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N%2==0:
    for c in range(kazu):
        list.append(n-c*2)
    nlist=list+list
    nlist.sort()
    if numbers==nlist:
        print(2**kazu)
    else:
        print(0)
else:
    for c in range(kazu):
        list.append(n-c*2)
    nlist=list+list+[0]
    nlist.sort()
    if numbers==nlist:
        print(2**kazu)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split()
numbers=[int(a) for a in A]
numbers.sort()
kazu=N//2
b=0
n=N-1
list=[]
nlist=[]
if N%2==0:
    for c in range(kazu):
        list.append(n-c*2)
    nlist=list+list
    nlist.sort()
    if numbers==nlist:
        print(2**kazu)
    else:
        print(0)
else:
    for c in range(kazu):
        list.append(n-c*2)
    nlist=list+list+[0]
    nlist.sort()
    if numbers==nlist:
        print(2**kazu)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_i = list(map(int, input().split()))
a_i.sort()
ans = 1
if max(a_i) >= n: ans = 0
else:
    for x in range(n //2):
        if n % 2 == 0:
            if a_i[2 * x] != 2 * x + 1 or a_i[2 * x + 1] != 2 * x + 1: ans = 0
            else: ans *= 2
        elif a_i[0] == 0 and n % 2 != 0:
            if a_i[2 * (x + 1) - 1] != 2 * (x + 1) or a_i[2 * (x + 1)] != 2 * (x + 1): ans = 0
            else: ans *= 2
        else: ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_i = list(map(int, input().split()))
a_i.sort()
ans = 1
for x in range(n //2):
    if n % 2 == 0:
        if a_i[2 * x] != 2 * x + 1 or a_i[2 * x + 1] != 2 * x + 1: ans = 0
        else: ans *= 2
    elif a_i[0] == 0 and n % 2 != 0:
        if a_i[2 * (x + 1) - 1] != 2 * (x + 1) or a_i[2 * (x + 1)] != 2 * (x + 1): ans = 0
        else: ans *= 2
    else: ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import collections
N = int(input())
A = list(map(int,input().split()))
A.sort()

Flg = True
if N % 2 == 1:
    a = A.pop(0)
    if a != 0:
        Flg = False

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if len(A)%2 == 0:
    result = 2**(len(A)//2)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)

Submission status: Wrong Answer

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

n = ((N+1) >> 1)
li = [0]*n


def mod_(b, x, n):
    r = b
    for i in range(1, x):
        r = (r * b) % n
    return int(r)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(2) != n-1:
        print(0)
    else:
        c = n-1
        print(mod_(2, c, 1E9+7))
else:
    if li.count(2) != n:
        print(0)
    else:
        c = n
        print(mod_(2, c, 1E9+7))

Submission status: Wrong Answer

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

li = [0]*((N+1) >> 1)


def mod_(b, x, n):
    acc = b
    for i in range(1, x):
        acc = (acc * b) % n
    return int(acc)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 1E9+7))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 1E9+7))

Submission status: Wrong Answer

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

li = [0]*((N+1) >> 1)


def mod_(b, x, n):
    acc = b
    for i in range(1, x):
        acc = (acc * b) % n
    return int(acc)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 10E9+7))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 10E9+7))

Submission status: Wrong Answer

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

li = [0]*((N+1) >> 1)


def mod_(b, x, n):
    acc = b
    for i in range(1, x):
        acc = (acc * b) % n
    return int(acc)


for a in A:
    if li[a >> 1] >= 2:
        print(0)
        break
    else:
        li[a >> 1] += 1

if N & 1:
    if li[0] != 1:
        print(0)
    elif li.count(1) > 1:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 10E9-7))
else:
    if li.count(1) > 0:
        print(0)
    else:
        c = li.count(2)
        print(mod_(2, c, 10E9-7))

Submission status: Wrong Answer

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

if len(A)%2 == 0:
    result = 2**(len(A)//2)
    for i in range(len(A)//2):
        if A.count(1+2*i) == 2:
            pass
        else:
            result = 0
            break
else:
    if A.count(0) == 1:
        result = 2**((len(A)//2)-1)
        for i in range(len(A)//2):
            if A.count(2*i) == 2:
                pass
            else:
                result = 0
                break
    else:
        result = 0
print(result)

Submission status: Wrong Answer

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

f = 1

if n%2 == 0:
    ans = [2]*(n//2)
    #print(ans)
    for i in range(n):
        if a[i]%2 == 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

else:
    ans = [2]*((n+1)//2)
    ans[0] -= 1
    for i in range(n):
        if a[i]%2 != 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

for i in range(len(ans)):
    if ans[i] != 0:
        f = 0
        break

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

Submission status: Wrong Answer

Solution code:
def main():
    people_num = int(input())
    information = sorted(list(map(int, input().split())))
    unique = len(set(information))
    answer = 0
    if unique * 2 == people_num + people_num % 2:
        if people_num > 1 and information[1] > 0:
            answer = 2 ** (unique - people_num % 2)
        elif people_num == 1 and information[0] == 0:
            answer = 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    people_num = int(input())
    information = sorted(list(map(int, input().split())))
    unique = len(set(information))
    answer = 0
    if unique * 2 == people_num + people_num % 2:
        if people_num > 1 and information[1] > 0:
            answer = (unique - people_num % 2) ** 2
        elif people_num == 1 and information[0] == 0:
            answer = 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

f = 1

if n%2 == 0:
    ans = [2]*(n//2)
    #print(ans)
    for i in range(n):
        if a[i]%2 == 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

else:
    ans = [2]*((n+1)//2)
    ans[0] -= 1
    for i in range(n):
        if a[i]%2 != 0:
            f = 0
            break
        x = a[i]//2
        ans[x] -= 1

for i in range(len(ans)):
    if ans[0] != ans[i]:
        f = 0
        break

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

Submission status: Wrong Answer

Solution code:
def main():
    from collections import Counter
    n=int(input())
    a=Counter(map(int,input().split()))

    if n%2==1:
        if 0 not in a:
            print(0)
            exit()
        else:
            if a[0]!=1:
                print(0)
                exit()
            else:
                a[0]=2
    
    for k,v in a.items():
        if v!=2 or (n-k-1)%2==1:
            print(0)
            exit()
            
    print(2**(n//2))  
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    a=[n-1+int(i) for i in input().split()]
    
    ans=[0]*n
    for i in range(n):
        t=a[i]
        if t%2==1:
            print(0)
            exit()
        t=t//2
        ans[t]+=1
        ans[-t-1]+=1
        if ans[t]>=3 or ans[-t-1]>=3:
            print(0)
            exit()
    
    print(2**(n//2))  
if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    numlist = dict()

    if n % 2 == 1:
        for i in range(0, n+1, 2):
            numlist[i] = []
    else:
        for i in range(1, n+1, 2):
            numlist[i] = []

    for aa in a:
        if aa not in numlist.keys():
            print('0')
            exit()
        numlist[aa].append(aa)

    for num in numlist:
        if num == 0 and len(numlist[num]) != 1:
            print('0')
            exit()
        elif num == 0 and len(numlist[num]) == 1:
            continue
        elif len(numlist[num]) != 2:
            print('0')
            exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

Submission status: Wrong Answer

Solution code:
import math
import sys

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

li = [0] * N
count = 0

if N % 2 == 0:
  t = 1
else:
  t = 0

for a in A:
  if a == 0:
    li[math.floor((N-1)/2)] += 1
    count += 1
    
    if count == 2:
      print(0)
      sys.exit()

    continue

  li[math.floor((N-1)/2)-math.floor(a/2)] += 1
  li[math.floor((N-1)/2)+math.floor(a/2)+t] += 1

ans = 1

for i in range(0, math.floor(N/2)):
  ans *= li[i]

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
count=defaultdict(lambda:0)
N=int(input())
A=list(input().split(" "))
k=-1
for i in range(N):
    count[A[i]]+=1
if N%2==1:
    if count["0"]!=1:
        k=0
    for i in range(1,N//2+1):
        if count[str(2*i)]!=2:
            k=0
else:
    for i in range(1,N//2+1):
        if count[str(2*i-1)]!=2:
            k=0
if k!=0:
    if N%2==0:
        print(2**(len(count.keys())))
    else:
        print(2**(len(count.keys())-1))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
count=defaultdict(lambda:0)
N=int(input())
A=list(input().split(" "))
k=-1
for i in range(N):
    count[A[i]]+=1
if N%2==1:
    if count["0"]!=1:
        k=0
    for i in range(1,N//2+1):
        if count[str(2*i)]!=2:
            k=0
else:
    for i in range(1,N//2+1):
        if count[str(2*i-1)]!=2:
            k=0
if k!=0:
    print(2**(len(count.keys())//2*2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
count=defaultdict(lambda:0)
N=int(input())
A=list(input().split(" "))
k=-1
for i in range(N):
    count[A[i]]+=1
for key in count.keys():
    if key=="0":
        if count["0"]!=1:
            k=0
            break
    else:
        if count[key]!=2:
            k=0
            break
if k!=0:
    print(2**(len(count.keys())//2*2))
else:
    print(0)

Submission status: Wrong Answer

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

d = [0]*n
for a in A:
    if a%2 == r:
        print(0)
        break
    d[a] += 1
    if (d[a] > 2) or (a == 0 and d[0] > 1):
        print(0)
        break
else:
    print(2**(n//2) % (10*9+7))

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
dat = list(map(int, input().split()))
dat.sort()
f = True
if n % 2 == 0: # 偶数
    for i in range(n):
        #print("try {0} == {1}".format(dat[i], 2 * (i // 2) + 1))
        if dat[i] != 2 * (i // 2) + 1:
            f = False
    if f:
        print(2 ** (n // 2))
else: # 奇数
    if dat[0] != 0:
        #print("no 0 ")
        f = False
    for i in range(n - 1):
        #print("try {0} == {1}".format(dat[i+1], 2 * (i//2 + 1)))
        if dat[i + 1] != 2 * (i//2 + 1):
            f = False
    if f:
        print(2** (n //2 ) )
if f is False:
    print(0)

Submission status: Wrong Answer

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

if n%2==1:
	if a.count(0)!=1:
		print(0)
		exit()
	n=int((n-1)/2)
	for j in range(n):
		if a.count((j+1)*2)!=2:
			print(0)
			exit()

if n%2==0:
	n=int(n/2)
	for j in range(n):
		if a.count(1+j*2)!=2:
			print(0)
			exit()
print(2**n)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
judge = 0
while 0 in A:
    A.remove(0)

A_ = list(set(A))
A_.sort()
for i in range(len(A_) - 1):
    if A_[i+1] == A_[i]+2:
        judge = 1
    else:
        judge = 0

if len(set(A)) == len(A)/2 and judge:
    print((2 ** (len(A) // 2)) % (10**9 +7))
else:
    print(0)

Submission status: Wrong Answer

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

while 0 in A:
    A.remove(0)
if len(set(A)) == len(A)/2:
    print(2 ** (len(A) // 2))
else:
    print(0)

Submission status: Wrong Answer

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

while 0 in A:
    A.remove(0)
if len(set(A))%2 == 0:
    print(2 ** (len(A) // 2))
else:
    print(0)

Submission status: Wrong Answer

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

while 0 in A:
    A.remove(0)
if len(A)%2 == 0:
    print(2 ** (len(A) // 2))
else:
    print(0)