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:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    #print(counter)
    if N % 2 == 0:
        # if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(1, N, 2):
        #     i = str(i)
        #     if counter[i] != 2:
        #         print("0")
        #         return
        for i in range(N):
            if i % 2 == 0:
                if str(i) in counter:
                    print("0")
                    return
                else:
                    continue
            i = str(i)
            if counter[i] != 2:
                print("0")
                return
    else:
        for i in range(N):
            if i % 2 == 1:
                if str(i) in counter:
                    print("0")
                    return
                else:
                    continue
            i = str(i)
            if i == "0":
                if counter[i] != 1:
                    print("0")
                    return
            else:
                 if counter[i] != 2:
                    print("0")
                    return
        # if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(0, N, 2):
        #     i = str(i)
        #     if i == "0":
        #         if counter[i] != 1:
        #             print("0")
        #             return
        #     else:
        #         if counter[i] != 2:
        #             print("0")
        #             return
    ans = 1
    for i in range(N//2):
        ans = (ans * 2) % (10 ** 9 + 7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    #print(counter)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if counter[i] != 2:
                print("0")
                return
        # for i in range(N):
        #     if i % 2 == 0 and (str(i) in counter):
        #         print("##")
        #         print(i)
        #         print("0")
        #         return
        #     i = str(i)
        #     if (i not in counter) or (counter[i] != 2):
        #         print("##")
        #         print(i)
        #         print("0")
        #         return
    else:
        # for i in range(N):
        #     if i % 2 == 1 and (str(i) in counter):
        #         print("##")
        #         print(i)
        #         print("0")
        #         return
        #     i = str(i)
        #     if i == "0":
        #         if (i not in counter) or (counter[i] != 1):
        #             print("##")
        #             print(i)
        #             print("0")
        #             return
        #     else:
        #          if (i not in counter) or (counter[i] != 2):
        #             print("##")
        #             print(i)
        #             print("0")
        #             return
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if counter[i] != 1:
                    print("0")
                    return
            else:
                if counter[i] != 2:
                    print("0")
                    return
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%((10**9)+7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        # if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(1, N, 2):
        #     i = str(i)
        #     if (i not in counter) or (counter[i] != 2):
        #         print("0")
        #         return
        for i in range(N):
            if i % 2 == 0 and (i in counter):
                print("0")
                return
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        for i in range(N):
            if i % 2 == 1 and (i in counter):
                print("0")
                return
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
        # if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(0, N, 2):
        #     i = str(i)
        #     if i == "0":
        #         if (i not in counter) or (counter[i] != 1):
        #             print("0")
        #             return
        #     else:
        #          if (i not in counter) or (counter[i] != 2):
        #             print("0")
        #             return
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%((10**9)+7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        # if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(1, N, 2):
        #     i = str(i)
        #     if (i not in counter) or (counter[i] != 2):
        #         print("0")
        #         return
        for i in range(N):
            if i % 2 == 0:
                print("0")
                return
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        for i in range(N):
            if i % 2 == 1:
                print("0")
                return
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
        # if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
        #     print("0")
        #     return
        # for i in range(0, N, 2):
        #     i = str(i)
        #     if i == "0":
        #         if (i not in counter) or (counter[i] != 1):
        #             print("0")
        #             return
        #     else:
        #          if (i not in counter) or (counter[i] != 2):
        #             print("0")
        #             return
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%((10**9)+7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%((10**9)+7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] > 2):
                print("0")
                return
    else:
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] > 2):
                    print("0")
                    return
    ans = 1
    for i in range(N//2):
        ans = (ans*2)%((10**9)+7)
    print(ans)



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
    print((2**(N//2))%((10**9)+7))



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
    print(2**(N//2)%((10**9)+7))



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        if list(map(str, range(1, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        if list(map(str, range(0, N, 2))).sort() != list(counter.keys()).sort():
            print("0")
            return
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
    print(2**(N//2))



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N = int(input())
    A = input().replace(" ", "")
    import collections
    counter = collections.Counter(A)
    if N % 2 == 0:
        for i in range(1, N, 2):
            i = str(i)
            if (i not in counter) or (counter[i] != 2):
                print("0")
                return
    else:
        for i in range(0, N, 2):
            i = str(i)
            if i == "0":
                if (i not in counter) or (counter[i] != 1):
                    print("0")
                    return
            else:
                 if (i not in counter) or (counter[i] != 2):
                    print("0")
                    return
    print(2**(N//2))



if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())))
mod = 10**9 + 7
B = []
if N % 2 == 0:
  for i in range(1, N//2 + 1):
    B.append(i*2 - 1)
    B.append(i*2 - 1)
else:
  for i in range(1, N//2 + 1):
    B.append(i*2)
    B.append(i*2)
  B.append(0)
B.sort()

if A != B:
  print(0)
else:
  if N % 2 == 0:
    print(pow(2, N//2), mod)
  else:
    print(pow(2, (N-1)//2), mod)

Submission status: Wrong Answer

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

B = []
if N % 2 == 0:
  for i in range(1, N//2 + 1):
    B.append(i*2 - 1)
    B.append(i*2 - 1)
else:
  for i in range(1, N//2 + 1):
    B.append(i*2)
    B.append(i*2)
  B.append(0)
B.sort()

if A != B:
  print(0)
else:
  if N % 2 == 0:
    print(pow(2, N//2))
  else:
    print(pow(2, (N-1)//2))

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
from collections import Counter
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().rstrip().split()))
    c = Counter(A)
    if N % 2 == 1:
        if c[0] != 1:
            print(0)
            return
        for i in range(2, N, 2):
            if c[i] != 2:
                print(0)
                return

    else:
        for i in range(1, N, 2):
            if c[i] != 2:
                print(0)
                return

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_ls = list(map(int, input().split()))
isOK = True
if n % 2 == 0:
    count_ls = [0] * n
    for a in a_ls:  
        count_ls[a] += 1
    if not count_ls == [0,2] * (n//2):
        isOK = False
else:
    count_ls = [0] * n
    for a in a_ls:  
        count_ls[a] += 1
    if not count_ls == [1] + [0,2] * (n//2):
        isOK = False
if isOK:
    ans = 2 ** (n // 2)
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_ls = list(map(int, input().split()))
isOK = True
if n % 2 == 0:
    count_ls = [0] * (n + 1)
    for i in range(n):  
        if count_ls[a_ls[i]] == 2:
            isOK = False
        count_ls[a_ls[i]] += 1
else:
    count_ls = [0] * (n + 1)
    for i in range(n):  
        if count_ls[a_ls[i]] == 2:
            isOK = False
        count_ls[a_ls[i]] += 1
    if count_ls[0] >= 2:
        isOK = False
if isOK:
    ans = 2 ** (n // 2)
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#Beginner 050 C

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

if L % 2 == 0:
    for a in A:
        if a % 2 == 1:
            continue
        else:
            print(0)
            quit()
    lst = [2*i+1 for i in range(L//2)]
    if set(lst) == set(A):
        print(2**(L//2))
    else:
        print(0)
        quit()
else:
    for a in A:
        if a % 2 == 0:
            continue
        else:
            print(0)
            quit()
    lst = [2*i for i in range(L//2+1)]
    if set(lst) == set(A):
        print(2**(L//2+1))
    else:
        print(0)
        quit()

Submission status: Wrong Answer

Solution code:
#Beginner 050 C

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

if L % 2 == 0:
    lst = [2*i+1 for i in range(L//2)]
    if set(lst) == set(A):
        print(2**(L//2))
    else:
        print(0)
        quit()
else:
    lst = [2*i for i in range(L//2+1)]
    if set(lst) == set(A):
        print(2**(L//2+1))
    else:
        print(0)
        quit()

Submission status: Wrong Answer

Solution code:
import collections

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

c = collections.Counter(l)
ans = 0
flag = True
if N%2==0:
    for i in range(1,N+1,2):
        if c[i] != 2:
            flag = False
else:
    for i in range(0,N+1,2):
        if i == 0 and c[i] != 1:
            flag = False 
        if i != 0 and c[i] != 2: 
            flag = False

if flag:
    ans = 2**int(N/2)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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


count = Counter(Alist)
res = 1
if N % 2 ==0:
    for i in range(1,N,2):
        if count[i] != 2:
            print(0)
            exit()
else:
    if count[0] != 1:
        print(0)
        exit()
    else:
        for i in range(2,N,2):
            count[i] != 2
            print(0)
            exit()
print(2**(N//2) % (10**9+7))

Submission status: Wrong Answer

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

if N % 2 ==0:
    for i in range(0,N//2):
        if Alist.count(2*i+1) != 2:
            print(0)
            exit()
    print(2**(N//2) % (10**9+7))

elif N % 2 ==1:
    if Alist.count(0) != 1:
        print(0)
        exit()
    else:
        for i in range(0,(N+1)//2):
            if Alist.count(2*i) != 2:
                print(0)
                exit()
    print(2**((N-1)//2) % (10**9+7))

Submission status: Wrong Answer

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

if N % 2 ==0:
    for i in range(0,N//2):
        if Alist.count(2*i+1) != 2:
            print(0)
            exit()
    print(2**(N//2) % (10**9+7))

elif N % 2 ==1:
    for i in range(0,(N+1)//2):
        if Alist.count(2*i) != 2:
            print(0)
            exit()
    print(2**((N-1)//2) % (10**9+7))

Submission status: Wrong Answer

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

if N % 2 ==0:
    for i in range(0,N//2):
        if Alist.count(2*i+1) != 2:
            print(0)
    print(2**(N//2) % (10**9+7))

elif N % 2 ==1:
    for i in range(0,(N+1)//2):
        if Alist.count(2*i) != 2:
            print(0)
    print(2**((N-1)//2) % (10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

for i in range(n):
    cnt[a[i]] += 1
flag = True

if 0 in cnt.keys():
    del cnt[0]

for i in range(n - 1, 0, -2):
    if cnt[i] != 2:
        flag = False
        break 
print(2 ** (n // 2) if flag else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

for i in range(n):
    cnt[a[i]] += 1
flag = True

if 0 in cnt.keys():
    del cnt[0]

for i in range(n - 1, 0, -2):
    if cnt[i] != 2:
        flag = False
        break 
print(2 ** len(cnt) if flag else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

for i in range(n):
    cnt[a[i]] += 1
flag = True

if 0 in cnt.keys():
    del cnt[0]
for k, v in cnt.items():
    if v != 2:
        flag = False
        break
print(2 ** len(cnt) if flag else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

for i in range(n):
    cnt[a[i]] += 1
flag = True
for k, v in cnt.items():
    if v > 2 or (k == 0 and v > 1) or (v < 2 and k != 0):
        flag = False
        break
if 0 in cnt.keys():
    del cnt[0]
print(2 ** len(cnt) if flag else 0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

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

if max(cnt.values()) > 2 or cnt[0] > 1:
    print(0)
else:
    del cnt[0]
    print(2 ** len(cnt))

Submission status: Wrong Answer

Solution code:
n = int(input())
num = list(map(int, input().split()))
mod = 10**9+7
ans = 1

if n%2==0:
    for i in range(n%2):
        if num.count(i*2+1)!=2:
            print(0)
            exit()
    for i in range(n//2):
        ans = ans*2%mod
    print(ans)
else:
    for i in range((n-1)//2):
        if num.count((i+1)*2)!=2:
            print(0)
            exit()
        if num.count(0)!=1:
            print(0)
            exit()
    for i in range((n-1)//2):
        ans = ans*2%mod
    print(ans)

Submission status: Wrong Answer

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

if n%2==0:
    for i in range(n%2):
        if num.count(i*2+1)!=2:
            print(0)
            exit()
    print(2**(n//2))
else:
    for i in range((n-1)//2):
        if num.count((i+1)*2)!=2:
            print(0)
            exit()
    print(2**((n-1)//2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=Counter(a)
c=len(([i[0] for i in b.items() if i[1] == 2]))

if n%2==0:
    if n//2==c:
        print(2**(len(set(a))))
    else:
        print(0)
else:
    if (n-1)//2==c and a.count(0)==1:
        print(2**(len(set(a))-1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
count = Counter(A)
flag = 0
if N % 2 == 0:
    for i in range(1, N, 2):
        if count[i] != 2:
            flag = 1
else:
    if count[1] != 1:
        flag = 1
    for i in range(2, N, 2):
        if count[i] != 2:
            flag = 1
if flag:
    print(0)
else:
    print((2 ** (N // 2)) % mod)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
flag = 0
if N % 2 == 0:
    for i in range(1, N, 2):
        if count[i] != 2:
            flag = 1
else:
    if count[0] != 1:
        flag = 1
    for i in range(2, N, 2):
        if count[i] != 2:
            flag = 1
if flag:
    print(0)
else:
    print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
mod = pow(10, 9) + 7

list_Counter = list(Counter(list_A).items())
ans = 1
list_Counter.sort(key=lambda x:x[0])

if n % 2 == 0:
    for i in range(n//2):
        l = list_Counter[i]
        if l[0] != 2*i or l[1] != 2:
            ans = -1

    if ans == -1:
        print(0)
    else:
        print((2**(n//2))%mod)
else:
    if list_Counter[0][0] == 0 and list_Counter[0][1] == 1:
        for i in range(1, n//2+1):
            l = list_Counter[i]
            if l[0] != 2*i or l[1] != 2:
                ans = -1
    else:
        ans = -1

    if ans == -1:
        print(0)
    else:
        print((2**(n//2))%mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
mod = pow(10, 9) + 7

list_Counter = list(Counter(list_A).items())
ans = 1
list_Counter.sort(key=lambda x:x[0])

if n % 2 == 0:
    for i in range(n//2):
        l = list_Counter[i]
        if l[0] != 2*i or l[1] != 2:
            ans = -1

    if ans == -1:
        print(ans)
    else:
        print((2**(n//2))%mod)
else:
    if list_Counter[0][0] == 0 and list_Counter[0][1] == 1:
        for i in range(1, n//2+1):
            l = list_Counter[i]
            if l[0] != 2*i or l[1] != 2:
                ans = -1
    else:
        ans = -1

    if ans == -1:
        print(ans)
    else:
        print((2**(n//2))%mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
list_A = list(map(int, input().split()))
mod = pow(10, 9) + 7

list_Counter = list(Counter(list_A).items())
ans = 1
list_Counter.sort(key=lambda x:x[0])

if n % 2 == 0:
    for i in range(n//2):
        l = list_Counter[i]
        if l[0] != 2*i and l[1] != 2:
            ans = -1

    if ans == -1:
        print(ans)
    else:
        print((2**(n//2))%mod)
else:
    if list_Counter[0][0] == 0 and list_Counter[0][1] == 1:
        for i in range(1, n//2+1):
            l = list_Counter[i]
            if l[0] != 2*i and l[1] != 2:
                ans = -1
    else:
        ans = -1

    if ans == -1:
        print(ans)
    else:
        print((2**(n//2))%mod)

Submission status: Wrong Answer

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

list_Counter = list(Counter(list_A).items())
ans = 1
list_Counter.sort(key=lambda x:x[0])

if n % 2 == 0:
    for i in range(n//2):
        l = list_Counter[i]
        if l[0] != 2*i and l[1] != 2:
            ans = -1

    if ans == -1:
        print(ans)
    else:
        print(2**(n//2))
else:
    if list_Counter[0][0] == 0 and list_Counter[0][1] == 1:
        for i in range(1, n//2+1):
            l = list_Counter[i]
            if l[0] != 2*i and l[1] != 2:
                ans = -1
    else:
        ans = -1

    if ans == -1:
        print(ans)
    else:
        print(2**(n//2))

Submission status: Wrong Answer

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

if sorted(a)!=b:
  ans=0
else:
  ans=2**(n//2)
print(ans)

Submission status: Wrong Answer

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

num = 2 ** (len(A) - len(set(A)))

if N // 2 != N / 2:
    try:
        A.remove(0)
    except:
        pass

X = [0] * len(A)

for i in range(len(A)):
    x = A.count(A[i])
    X[i] = x

if set(X) == {2}:
    print(num)
else:
    print(0)

Submission status: Wrong Answer

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

num = 2 ** (len(A) - len(set(A)))
check1 = N // 2
check2 = N / 2


if check1 == check2:
    if sum(A) == (max(A) + 1)*check1:
        print(num)
    else:
        print(0)
else:
    if sum(A) == (max(A) + 2)*check1:
        print(num)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in a:
  if ((i+n)%2 == 0) and (i != 0):
    print(0)
    exit()
  if i in d:
    d[i] += 1
    if (d[i] == 3) or (i == 0):
      print(0)
      exit()
  else:
    d[i] = 1
ans = 1
for i in list(d.values()):
  ans *= i
print(ans%1000000009)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in a:
  if ((i+n)%2 == 0) and (i != 0):
    print(0)
    exit()
  if i in d:
    d[i] += 1
    if (d[i] == 3) or (i == 0):
      print(0)
      exit()
  else:
    d[i] = 1
ans = 1
for i in list(d.values()):
  ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in a:
  if (i+n)%2 == 0:
    print(0)
    exit()
  if i in d:
    d[i] += 1
    if (d[i] == 3) or (i == 0):
      print(0)
      exit()
  else:
    d[i] = 1
ans = 1
for i in list(d.values()):
  ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in a:
  if i in d:
    d[i] += 1
    if (d[i] == 3) or (i == 0):
      print(0)
      exit()
  else:
    d[i] = 1
ans = 1
for i in list(d.values()):
  ans *= i
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 1
if n%2!=0:
  if l.count(0)!=1:
    s =0
  else:
    l.remove(0)
    if len(set(l))==(n-1)//2:
      s = (2**(n-1))//2
    else:
      s =0
else:
    if len(set(l))==n//2:
      s = 2**(n//2)
    else:
      s = 0
print(int(s)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 1
if n%2!=0:
  if l.count(0)!=1:
    s =0
  else:
    l.remove(0)
    if len(set(l))==(n-1)//2:
      s = 2*(n-1)//2
    else:
      s =0
else:
    if len(set(l))==n//2:
      s = 2*(n//2)
    else:
      s = 0
print(int(s)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
s = 1
if n%2!=0:
  l1 = [i for i in range(0,n,2)]
  for i in l1:
    a = l.count(i)
    if not ( (i==0 and a==1) or (i!=0 and a==2)):
      s = 0
      break
  else:
    s = 2*(n-1)//2
else:
  l1 = [i for i in range(1,n,2)]
  for i in l1:
    a=l.count(i)
    if a!=2:
      s = 0
      break
  else:
    s = 2*(n//2)
print(int(s)%(10**9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a=sorted(a)
cnt=0
if len(a)%2==0:
  for i in range(1,len(a),2):
    if [i,i]==a[i-1:i+1]:
      cnt+=1
    else:
      cnt=-10**5-1
else:
  if a[0]==0:
    for i in range(2,len(a),2):
      if [i,i]==a[i-1:i+1]:
        cnt+=1
      else:
        cnt=-10**5-1
  else:
    cnt=-10**5-1
print((2**cnt)%(10**9+7) if cnt>0 else 0)