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())
l=list(map(int,input().split()))
s=1
l.sort()
for i,x in enumerate(l):
    if n%2:
        if i%2:
            if i+1!=x:
                s=0
                break
        else:
            if i!=x:
                s=0
                break
    else:
        if i%2==0 and i+1!=x:
            s=0
            break
        else:
            if i!=x:
                s=0
                break
        
            
if s:
    print((int((n/2))**2)%(10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections

n=int(input())
l=list(map(int,input().split()))
s=collections.Counter(l)
s=s.most_common()
print(s)
a=1
if n%2==0:
    for i in s:
        if i[1]!=2:
            print(0)
            exit()
        elif i[0]%2!=1 or i[1]//2>n//2:
            print(0)
            exit()
    else:
        for j in range(n//2):
            a=(2*a)%1000000007
    print(a)
elif n%2==1:
    if (0,1) not in s:
        print(0)
        exit()
    else:
        del s[-1]
        print(s)
        for i in s:
            if i[1]!=2 or i[0]%2!=0 or i[0]//2>n//2:
                print(0)
                exit()
        else:
            for j in range(n//2):
                a=(2*a)%1000000007
    print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i != 0 and (n%2 == i%2):
        print(0)
        break
    if i in nums:
        if nums[i] <= 1:
            nums[i] += 1
        else:
            print(0)
            break
    else:
        nums[i] = 1
else:        
    del nums[0]        
    
    if 1 in list(nums.values()):
        print(0)
    else:
        print(2**len(nums.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i != 0 and (n%2 == i%2):
        print(0)
        break
    if i in nums:
        if nums[i] <= 1:
            nums[i] += 1
        else:
            print(0)
            break
    else:
        nums[i] = 1
else:        
    del nums[0]        
    
    if 1 in nums.values():
        print(0)
    else:
        print(2**len(nums.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i in nums:
        if nums[i] <= 1:
            nums[i] += 1
        else:
            print(0)
            break
    else:
        nums[i] = 1
        
del nums[0]        

if 1 in nums.values():
    print(0)
else:
    print(2**len(nums.values()))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = {0:0}

for i in list(map(int, input().split())):
    if i in nums:
        if nums[i] <= 1:
            nums[i] += 1
        else:
            print(0)
            break
    else:
        nums[i] = 1
        
del nums[0]        

if 1 in nums.values():
    print(0)
else:
    print(2**len(nums.values()))
    
print(nums)

Submission status: Wrong Answer

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

ans = 1
count = 0
if N == 1:
    if A[0] == 0:
        ans = 1
    else:
        print(0)

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

            else:
                ans = 0
    else:
        ans = 0
for i in range(count):
    ans *= 2
    ans %= 1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
ans = 1
if N == 1:
    if A[0] == 0:
        print(ans)
    else:
        print(0)

if N % 2 == 0:
    for i in range(1, int(N/2)+1):
        if A.count(i*2-1) == 2:
            ans *= 2
            ans %= 1000000007
        else:
            ans *= 0
else:
    if A.count(0) == 1:
        for i in range(1, int(N/2)+1):
            if A.count(i*2) == 2:
                ans *= 2
                ans %= 1000000007
            else:
                ans *=0
    else:
        ans *= 0
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=sorted([i for i in range((N+1)%2, N, 2)]*2)
if N%2 == 1:
    s.pop(0)
print(2**(N//2) if sorted([int(i) for i in input().split()])==s else 0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()

As = sorted(A)
OE = N % 2
if OE == 1:
    As.pop(0)
for i in range (0, N-OE, 2):
    #print(As[i])
    if As[i] != As[i + 1]:
        print(0)
        exit()
    if As[i] != str(i + 1 + OE):
        print(0)
        exit()

print(int(pow(2, int((N-OE)/2)) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()

As = sorted(A)
OE = N % 2
if OE == 1:
    As.pop(0)
i = 1
while(len(As) > 0):
    #print(As)
    if As[0] == As[1] == str(i * 2 - 1 + OE):
        As.pop(0)
        As.pop(0)
    else:
        print(0)
        exit()
    i = i + 1
print(int(pow(2, int((N-OE)/2)) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()

As = sorted(A)
OE = N % 2
if OE == 1:
    As.pop(0)
i = 1
while(len(As) > 0):
    #print(As)
    if As[0] == As[1] == str(i * 2 - 1 + OE):
        As.pop(0)
        As.pop(0)
    else:
        print(0)
        exit()
    i = i + 1
print(int(pow(2, (N-OE)/2) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()

As = sorted(A)
OE = N % 2
if OE == 1:
    As.pop(0)
i = 1
while(len(As) > 0):
    print(As)
    if As[0] == As[1] == str(i * 2 - 1 + OE):
        As.pop(0)
        As.pop(0)
    else:
        print(0)
        exit()
    i = i + 1
print(int(pow(2, (N-OE)/2) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()
OE = N % 2
if OE == 1 and '0' not in A:
    print(0)
    exit()
if OE == 1 and '0' in A:
    A.remove('0')

for i in range(1 ,int((N-OE)/2)+OE):
    count = 0
    for item in A:
        if item == str(i * 2 + 1 - OE):
            A.remove(str(i * 2 + 1 - OE))
            count = count + 1
        if count == 2:
            break
    if count < 2:
        print(0)
        exit()

print(int(pow(2, (N-OE)/2) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()
OE = N % 2
if OE == 1 and '0' in A:
    A.remove('0')
if OE == 1 and '0' not in A:
    print(0)
    exit()
for i in range(1 ,int((N-OE)/2)+OE):
    if A.count(str(i * 2 + 1 - OE)) == 2:
        A.remove(str(i * 2 + 1 - OE))
        A.remove(str(i * 2 + 1 - OE))
        continue
    else:
        print(0)
        exit()
print(int(pow(2, (N-OE)/2) % (pow(10, 9) + 7)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
A = input().split()
OE = N % 2
flag = 0
for i in range(1 ,int((N-OE)/2)+OE):
    if A.count(str(i * 2 + 1 - OE)) == 2:
        continue
    else:
        print(0)
        flag = 1
if flag == 0:
    print(pow(2, (N-OE)/2) % (pow(10, 9) + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
A.sort()
mod = 7 + 10**9
Appropriate = True
ans = 1

if N % 2 == 0: #報告値はすべて奇数かつ1~N-1まで2回ずつ出る必要がある
    i = 0
    while i < N:
        if A[i] != i+1 or A[i+1] != i+1:
            Appropriate = False
            break
        else:
            ans *= 2
            ans %= mod
            i+=2
else: #報告値はすべて偶数で0が1回、2~N-1が2回ずつ出る必要がある
    i = 1
    if A[0] != 0 or A.count(0) > 2:
        Appropriate = False
    else:
        while i < N:
            if A[i] != i+1 or A[i+1] != i+1:
                Appropriate = False
                break
            else:
                ans *= 2
                ans %= mod
                i += 2

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
mod = int(10e9+7)

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
flag = 1
for i, j in dic.items():
    if i == 0:
        if j != 1:
            flag = 0
    else:
        if j != 2:
            flag = 0
if flag:
    print(pow(2, n//2)%mod)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
mod = int(10e9+7)

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
flag = 1
for i, j in dic.items():
    if i == 0:
        if j != 1:
            flag = 0
    else:
        if j != 2:
            flag = 0
if flag:
    print(pow(n//2, 2)%mod)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
mod = int(10e9+7)

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
flag = 1
for i, j in dic.items():
    if i == 0:
        if j != 1:
            flag = 0
    else:
        if j != 2:
            flag = 0
if flag:
    if n & 1:
        n -= 1
    print(pow(n//2, 2)%mod)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
a = il()
dic = dict()
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
flag = 1
for i, j in dic.items():
    if i == 0:
        if j != 1:
            flag = 0
    else:
        if j != 2:
            flag = 0
if flag:
    if n & 1:
        n -= 1
    print(pow(n//2, 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

mod = 10 ** 9 + 7
c = Counter(A)

ans = 1
for v in c.values():
    if v == 2:
        ans *= 2
    else:
        ans = 0
        break
    ans %= mod
print(ans)

Submission status: Wrong Answer

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

from collections import Counter

def f():
    cnt = Counter(A)
    test = True
    m = len(A) // 2
    for k, v in cnt.items():
        if v == 1:
            if test == True:
                test = False
                continue
        if v != 2 or k > m:
            return 0
    return pow(2, len(A)//2, 10**9 + 7)

print(f())

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
def main():
    if A[0] == N % 2:
        print(0)
        return 0
    if len(A) == 1 and A[0] == 0:
        print(1)
        return 0
    else:
        print(0)
        return 0
    if A[0] == 0:
        del A[0]
    if A[0] == 0:
        print(0)
        return 0
    i = 1
    while True:
        if i >= len(A):
            break
        if len(A) % 2 != 0:
            print(0)
            return 0
        if A[i] != A[i - 1]:
            print(0)
            return 0
        i += 2
    i = 2
    while True:
        if i >= len(A):
            break
        if A[i] == A[i - 1]:
            print(0)
            return 0
        i += 2
    print(pow(2, len(A) // 2) % 1000000007)
main()

Submission status: Wrong Answer

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

dic = {}
ans = 1

for Ai in A:
    if Ai not in dic:
        dic[Ai] = 1
    else:
        dic[Ai] += 1

for t in dic.items():
    ans *= N % 2 != t[0] % 2

    if t[0] == 0:
        ans *= t[1] == 0
    else:
        ans = (ans * 2 * (t[1] == 2)) % (10 ** 9 + 7)

print(ans)

Submission status: Wrong Answer

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

dic = {}
ans = 1

for Ai in A:
    if Ai not in dic:
        dic[Ai] = 1
    else:
        dic[Ai] += 1

for t in dic.items():
    ans *= int(N % 2 != t[0] % 2)

    if t[0] == 0:
        ans *= int(t[1] == 0)
    else:
        ans = (ans * 2 * int(t[1] == 2) % (10 ** 9 + 7))

print(ans)

Submission status: Wrong Answer

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

dic = {}
ans = 1

for Ai in A:
    if Ai not in dic:
        dic[Ai] = 1
    else:
        dic[Ai] += 1

for t in dic.items():
    ans *= N % 2 != t[0] % 2

    if t[0] == 0:
        ans *= t[1] == 0
    else:
        ans = (ans * 2 * (t[1] == 2) % (10 ** 9 + 7))

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
import math
x=[0 for _ in range(n)]
if n%2!=0:
    x[0]+=1
for i in range(n):
    x[a[i]]+=1

j=True
for t in x:
    if t%2!=0:
        j=False
print(2**(n//2) if j else 0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
import math
x=[0 for _ in range(math.ceil(n/2))]
if n%2!=0:
    x[0]+=1
for i in range(n):
    x[a[i]//2]+=1

j=True
for t in x:
    if t!=2:
        j=False
print(2**(n//2) if j else 0)

Submission status: Wrong Answer

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

ctr = Counter(A)
if N%2 and ctr[0] != 1:
    print(0)
    exit()

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

MOD = 10**9+7
ans = pow(N//2, 2, MOD)
print(ans)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

if N % 2 == 1:
    if input_list[0] != 0:
        print(0)
    else:
        if N == 1:
            print(1)
        flag = 2
        limit = (N - 1) // 2
        for i in range(1, limit, 2):
            if input_list[i] == flag and input_list[i+1] == flag:
                flag += 2
                if i == limit-1:
                    print((2**limit) % mod)
            else:
                print(0)
                break
elif N % 2 == 0:
    flag = 1
    limit = N // 2
    for i in range(0, limit, 2):
        if input_list[i] == flag and input_list[i+1] == flag:
            flag += 2
            if i == limit-2:
                print((2**limit) % mod)
        else:
            print(0)
            break

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

if N % 2 == 1:
    if input_list[0] != 0:
        print(0)
    else:
        flag = 2
        limit = (N - 1) // 2
        for i in range(1, limit, 2):
            if input_list[i] == flag and input_list[i+1] == flag:
                flag += 2
                if i == limit-1:
                    print((2**limit) % mod)
            else:
                print(0)
                break
elif N % 2 == 0:
    flag = 1
    limit = N // 2
    for i in range(0, limit, 2):
        if input_list[i] == flag and input_list[i+1] == flag:
            flag += 2
            if i == limit-2:
                print((2**limit) % mod)
        else:
            print(0)
            break

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

if N % 2 == 1:
    if input_list[0] != 0:
        print(0)
    else:
        flag = 2
        limit = (N - 1) // 2
        for i in range(1, limit, 2):
            if input_list[i] == flag and input_list[i+1] == flag:
                flag += 2
                if i == limit-1:
                    print((2**limit) % mod)
            else:
                print(0)
                break
elif N % 2 == 0:
    flag = 1
    limit = N // 2
    for i in range(0, limit, 2):
        if input_list[i] == flag and input_list[i+1] == flag:
            flag += 2
            if i == limit-1:
                print((2**limit) % mod)
        else:
            print(0)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
rec = [0] * n
mod = 10 ** 9 + 7
if n % 2 == 0:
    for i in range(n):
       rec[a[i]] += 1

    flag = True
    for i in range(n):
        if rec[i] > 2:
            flag = False

    if rec[0] == 0 and flag:
        print(((n // 2) ** 2) % mod)
    else:
        print(0)
else:
    for i in range(n):
       rec[a[i]] += 1

    flag = True
    for i in range(n):
        if rec[i] > 2:
            flag = False

    if rec[0] == 1 and flag:
        print(((n // 2) ** 2) % mod)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
rec = [0] * n
mod = 10 ** 9 + 7
if n % 2 == 0:
    for i in range(n):
       rec[a[i]] += 1

    flag = True
    for i in range(1, n, 2):
        if rec[i] != 2:
            flag = False

    if rec[0] == 0 and flag:
        print(((n // 2) ** 2) % mod)
    else:
        print(0)


else:
    for i in range(n):
       rec[a[i]] += 1

    flag = True
    for i in range(2, n, 2):
        if rec[i] != 2:
            flag = False

    if rec[0] == 1 and flag:
        print(((n // 2) ** 2) % mod)
    else:
        print(0)

Submission status: Wrong Answer

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

    flag = True
    for i in range(1, n, 2):
        if rec[i] != 2:
            flag = False

    if rec[0] == 0 and flag:
        print((n // 2) ** 2)
    else:
        print(0)


else:
    for i in range(n):
       rec[a[i]] += 1

    flag = True
    for i in range(2, n, 2):
        if rec[i] != 2:
            flag = False

    if rec[0] == 1 and flag:
        print((n // 2) ** 2)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
a = list(map(int,input().split()))
g = itertools.groupby(sorted(a))
for i,(k,v) in enumerate(g):
    if n%2==1:
        f1 = i==0 and k==0 and len(list(v))==1
        f2 = i!=0 and k==i*2 and len(list(v))==2
        if not (f1 or f2):
            print(0)
            exit()
    else:
        if k!=2*i+1 or len(list(v))!=2:
            print(0)
            exit()
print((n//2)**2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
from collections import Counter

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    counter = Counter(a_list)

    ans = 1
    if n % 2 != 0:
        for i in range(0, n, 2):
            c = counter[i]
            if (i == 0 and c != 1) or c == 0:
                print(0)
                exit()
            else:
                ans *= c
    else:
        for i in range(1, n, 2):
            c = counter[i]
            if c == 0:
                print(0)
                exit()
            else:
                ans *= c
    print(ans)
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = tuple(map(int, input().split(" ")))
# n = 10000
# a = tuple(sum([[i, i] for i in range(1, n+1, 2)], [])[:n])

a_values = list(Counter(a).values())

if set(a_values[-(n//2):]) == {2}:
    print((2 ** (n//2)) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = tuple(map(int, input().split(" ")))
# n = 10000
# a = tuple(sum([[i, i] for i in range(1, n+1, 2)], [])[:n])

a_values = list(Counter(a).values())

if set(a_values[-(n//2):]) == {2}:
    print(2 ** (n//2) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = tuple(map(int, input().split(" ")))
# n = 10000
# a = tuple(sum([[i, i] for i in range(1, n+1, 2)], [])[:n])

a_values = list(Counter(a).values())

if int(n%2==0) in a_values:
    a_values.remove(int(n%2==0))
if set(a_values) == {2}:
    print(2 ** (n//2) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

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

nums_sample = sum([[i, i] for i in range(n-1, 0-1, -2)], [])[:n]

if sorted(a, reverse=True) == nums_sample:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

cnt = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        cnt[A[i]] += 1
        if cnt[A[i]] > 2:
            print(0)
            exit()
        if cnt[A[i]] == 1:
            ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            cnt[A[i]] += 1
            if cnt[A[i]] > 2:
                print(0)
                exit()
            if cnt[A[i]] == 1:
                ans = (ans * 2) % (10 ^ 9 + 7)
        if A[i] == 0:
            cnt[0] += 1
            if cnt[0] > 1:
                print(0)
                exit()
    print(ans)

Submission status: Wrong Answer

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

count = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        count[A[i]] += 1
        if count[A[i]] > 2:
            print(0)
            exit()
        if count[A[i]] == 1:
            ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        if A[i] > 0:
            count[A[i]] += 1
            if count[A[i]] > 2:
                print(0)
                exit()
            if count[A[i]] == 1:
                ans = (ans * 2) % (10 ^ 9 + 7)
        else:
            count[0] += 1
            if count[0] > 1:
                print(0)
                exit()
    print(ans)

Submission status: Wrong Answer

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

count = [0 for i in range(N)]
ans = 1

if N % 2 == 0:
    for i in range(N):
        if A[i] % 2 == 0:
            print(0)
            exit()
        count[A[i]] += 1
        if count[A[i]] > 2:
            print(0)
            exit()
        if count[A[i]] == 1:
            ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)
else:
    for i in range(N):
        if A[i] % 2 == 1:
            print(0)
            exit()
        elif A[i] > 0:
            count[A[i]] += 1
            if count[A[i]] > 2:
                print(0)
                exit()
            if count[A[i]] == 1:
                ans = (ans * 2) % (10 ^ 9 + 7)
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
f = True
if N % 2 == 1:
    if A[0] != 1:
        f = False
    else:
        del A[0]
    if set(A) != set(range(2, N, 2)) or set(A.values()) != {2}:
        f = False
else:
    if set(A) != set(range(1, N, 2)) or set(A.values()) != {2}:
        f = False
if not f:
    print(0)
else:
    print(2 ** len(A.values()) % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
import numpy as np

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


if len(a)%2 == 1:
    temp = int((len(a) - 1)/2)
    ans = 1
    for k in range(temp):
        ans = (ans * 2)%mod
              
    if sum(a == 0) != 1:
        ans = 0
    else:
        a = a[a!=0]
else:
    temp = int((len(a))/2)
    ans = 1
    for k in range(temp):
        ans = (ans * 2)%mod
    a = a+1

cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

for c in cands:
    if sum(a == c) != 2:
        ans = 0
        break

print(ans)

Submission status: Wrong Answer

Solution code:
try:
    import numpy as np

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

    if len(a)%2 == 1:
        temp = int((len(a) - 1)/2)
        aaaaaa
        ans = 1
        for k in range(temp):
            ans = (ans * 2) %x
        if sum(a == 0) != 1:
            ans = 0
        else:
            a = a[a!=0]
    else:
    #     ans = 2**(temp)%(1e9 + 7)
        temp = int((len(a))/2)
        ans = 1
        for k in range(temp):
            ans = (ans * 2) %x
        a = a+1

    cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

    b,bb = np.unique(a,return_counts=True)
    if sum(bb == 2) != len(a)/2:
        ans = 0
    b == np.array(cands)
    for bbb, ccc in zip(b,cands):
        if bbb != ccc:
            ans = 0
            break

    print(ans)
except:
    print(0)

Submission status: Wrong Answer

Solution code:
try:
    import numpy as np

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

    if len(a)%2 == 1:
        temp = int((len(a) - 1)/2)
        ans = int((2**(temp % 30) + (temp//30) * x) % x)
        if sum(a == 0) != 1:
            ans = 0
        else:
            a = a[a!=0]
    else:
    #     ans = 2**(temp)%(1e9 + 7)
        temp = int((len(a))/2)
        ans = int((2**(temp % 30) + (temp//30) * x) % x)
        a = a+1

    cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

    b,bb = np.unique(a,return_counts=True)
    if sum(bb == 2) != len(a)/2:
        ans = 0
    b == np.array(cands)
    for bbb, ccc in zip(b,cands):
        if bbb != ccc:
            ans = 0
            break

    print(ans)
except:
    print(0)

Submission status: Wrong Answer

Solution code:
try:
    import numpy as np

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

    if len(a)%2 == 1:
        temp = int((len(a) - 1)/2)
        int((2**(temp % 30) + (temp//30) * x) % x)
        if sum(a == 0) != 1:
            ans = 0
        else:
            a = a[a!=0]
    else:
    #     ans = 2**(temp)%(1e9 + 7)
        temp = int((len(a))/2)
        int((2**(temp % 30) + (temp//30) * x) % x)
        a = a+1

    cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

    b,bb = np.unique(a,return_counts=True)
    if sum(bb == 2) != len(a)/2:
        ans = 0
    b == np.array(cands)
    for bbb, ccc in zip(b,cands):
        if bbb != ccc:
            ans = 0
            break

    print(ans)
except:
    print(0)

Submission status: Wrong Answer

Solution code:
try:
    import numpy as np

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


    if len(a)%2 == 1:
        ans = int(2**((len(a) - 1)/2)%(1e9 + 7))
        if sum(a == 0) != 1:
            ans = 0
        else:
            a = a[a!=0]
    else:
        ans = int(2**((len(a))/2)%(1e9 + 7))
        a = a+1

    cands = [2*k for k in range(1,int(len(a)/2) + 1)] * 2

    for c in cands:
        if sum(a == c) != 2:
            ans = 0
            break

    print(ans)
except:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
a = list(map(int,input().split()))
mod = (10**9+7)
if N%2 !=0:
    if sum(a)%2!=0 or max(a)>N or a.count(0)!=1 or len(set(a))!=N//2+1:
        print(0)
    else:
        print(2**(len(set(a))-1)//mod)
elif N%2 ==0:
    if sum(a)%2!=0 or max(a)>N or len(set(a))!=N//2:
        print(0)
    else:
        print(2**len(set(a))//mod)

Submission status: Wrong Answer

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

if N%2 !=0:
    if sum(a)%2!=0 or max(a)>N or a.count(0)!=1 or len(set(a))!=N//2+1:
        print(0)
    else:
        print(2**(len(set(a))-1))
elif N%2 ==0:
    if sum(a)%2!=0 or max(a)>N or len(set(a))!=N//2:
        print(0)
    else:
        print(2**len(set(a)))

Submission status: Wrong Answer

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

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

a_sorted = sorted(a)

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

Submission status: Wrong Answer

Solution code:
import sys

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

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

table = [0] * n
for i in range(n):
    s1 = (a[i] + n - 1) / 2
    s2 = n - 1 - s1
    if not is_integer_num(s1):
        print(0)
        sys.exit()

    x1 = int(s1)
    x2 = int(s2)
    if x1 != x2:
        table[x1] += 1
        table[x2] += 1
    else:
        table[x1] += 1

if (n % 2) == 0:
    for i in range(n):
        if table[i] != 2:
            print(0)
            sys.exit()
else:
    for i in range(n):
        mid = n // 2
        if i == mid:
            if table[i] != 1:
                print(0)
                sys.exit()
        else:
            if table[i] != 2:
                print(0)
                sys.exit()
ans = int(pow(n // 2, 2) % (10e9 + 7))
print(ans)

Submission status: Wrong Answer

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

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

BN = [0] * (N//2+1)

# 偶奇で分けて集計
for i in range(N):
    if N % 2 != 0:
        BN[N//2 - AN[i]//2] += 1
    else:
        BN[N//2 - (AN[i]//2+1)] += 1

# 偶数の場合は真ん中を考慮
ans = 0
for i in range(len(BN)):
    if BN[i] > 2 or N % 2 != 0 and BN[-1] > 1:
        print(0)
        exit()

# 結果出力
print(2 ** (N//2))