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

if N % 2 == 1:
    l.append(0)
    N -= 1
else:
    l = list(map(lambda x: x-1, l))

l = sorted(l)
i = 0
for f, s in zip(l[0::2], l[1::2]):
    if f == s == 2*i:
        i += 1
    else:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

if N % 2 == 1:
    l.append(0)
    N -= 1

l = sorted(l)
i = 0
for f, s in zip(l[0::2], l[1::2]):
    if f == s == 2*i:
        i += 1
    else:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

ans = 0

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

if N % 2 == 1:
    l.append(0)
    N -= 1
C = Counter(l)

if all(v == 2 for v in C.values()):
    ans = 2**(N//2)
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(int(i) for i in input().split())
if n%2==0 and sum(a)==n*n//2 or n%2 ==1 and sum(a) == (n+1)*n//2:
    print(2**(n//2)%(10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(int(i) for i in input().split())
if n%2==0 and sum(a)==n*n//2 or n%2 ==1 and sum(a) == (n+1)*n//2:
    print(2**(n//2)%(10**9+7))

Submission status: Wrong Answer

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

A.sort()

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

Submission status: Wrong Answer

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

A.sort()

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

Submission status: Wrong Answer

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
count = 1
if a % 2 == 1:
    for i in range(0,a,2):
        if i == 0:
            if ar.count(0) != 1:
                count = 0
                break
        else:
            if ar.count(i) != 2:
                count = 0
                break
            else:
                count *= 2
else:
    for i in range(1,a,2):
        if ar.count(i) != 2:
            count = 0
            break
        else:
            count *= 2
        print(i)
print(count)

Submission status: Wrong Answer

Solution code:
def inpl(): return [int(i) for i in input().split()]
import sys
from collections import defaultdict
H = defaultdict(lambda: 0)
N = int(input())
A = inpl()
if N%2:
    H[0] = -1
    for i in range(1, 1+N//2):
        H[2*i] = -2
else:
    for i in range(1, 1+N//2):
        H[2*i-1] = -2
for i in A:
    H[i] += 1
H = list(H.values())
if any(H):
    print(0)
    sys.exit()
print(2**(N//2))

Submission status: Wrong Answer

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

check = [0]*(n//2 + n%2)
flag = True
for i in a:
    check[i//2] += 1
    if i%2 == n%2:
        flag = False
        break
    if (i//2 == 0 and n%2 == 1 and check[0] > 1) or check[i//2] > 2:
        flag = False
        break
if flag:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

check = [0]*(n//2 + n%2)
flag = True
for i in a:
    check[i//2] += 1
    if (i//2 == 0 and n%2 == 1 and check[0] > 1) or check[i//2] > 2:
        flag = False
        break
if flag:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

check = [0]*(n//2 + n%2)
flag = True
for i in a:
    check[i//2] += 1
    if (i//2 == 0 and n%2 and check[0] > 1) or check[i//2] > 2:
        flag = False
        break
if flag:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

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

cnt = Counter(A)

sA = sorted(A)

if N % 2 == 0:
    i = 0
    for i in range(0, N - 1, 2):
        if sA[i] == sA[i + 1] and sA[i] == i + 1:
            pass
        else:
            print(0)
            sys.exit(0)
else:
    i = 0
    if sA[i] != 0:
        print(0)
        sys.exit(0)
    for i in range(1, N - 1, 2):
        if sA[i] == sA[i + 1] and sA[i] == i + 1:
            pass
        else:
            print(0)
            sys.exit(0)

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

sys.exit(0)

Submission status: Wrong Answer

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


def solve():
    cnt = {i + (1 - N % 2): 0 for i in range(0, 2 * N // 2, 2)}
    for a in A:
        if a not in cnt:
            return 0
        
        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            cnt[a] += 1

    for key, value in cnt.items():
        if key == 0:
            if value != 1:
                return 0
        else:
            if value != 2:
                return 0

    return 2 ** (N // 2)


print(solve())

Submission status: Wrong Answer

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


def solve():
    cnt = {i + (1 - N % 2): 0 for i in range(0, 2 * N // 2, 2)}
    for a in A:
        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            cnt[a] += 1

    for key, value in cnt.items():
        if key == 0:
            if value != 1:
                return 0
        else:
            if value != 2:
                return 0

    return 2 ** (N // 2)


print(solve())

Submission status: Wrong Answer

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


def solve():
    cnt = {}
    for a in A:
        if a not in cnt.keys():
            cnt[a] = 0

        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            cnt[a] += 1
            
    for key, value in cnt.items():
        if key == 0:
            if value != 1:
                return 0
        else:
            if value != 2:
                return 0
    
    return 2 ** (N // 2)


print(solve())

Submission status: Wrong Answer

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


def solve():
    cnt = {}
    for a in A:
        if a not in cnt.keys():
            cnt[a] = 0

        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            else:
                if a == 0 and cnt[a] > 0:
                    return 0
                elif a != 0 and cnt[a] > 1:
                    return 0
                cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            else:
                if cnt[a] > 1:
                    return 0
                cnt[a] += 1
    return 2 ** (N // 2)


print(solve())

Submission status: Wrong Answer

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


def solve():
    cnt = {}
    for a in A:
        if a not in cnt.keys():
            cnt[a] = 0

        if N % 2 == 1:
            if a % 2 == 1:
                return 0
            else:
                if a == 0 and cnt[a] > 0:
                    return 0
                elif a != 0 and cnt[a] > 1:
                    return 0
                cnt[a] += 1
        else:
            if a % 2 == 0:
                return 0
            else:
                if cnt[a] > 1:
                    return 0
    return 2 ** (N // 2)


print(solve())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag=True
if N%2==0:
    l = [0 for i in range(N/2)]
    for i in range(N):
        if A[i]%2!=1 or A[i]>=N or A[i]<=0:
            print 0
            flag=False
            break
        l[(A[i]-1)/2]+=1
        if l[(A[i]-1)/2]>=3:
            print 0
            flag=False
            break
    if flag:
        print 2**(N/2)
else:
    l = [0 for i in range((N+1)/2)]
    for i in range(N):
        if A[i]%2!=0 or A[i]>=N or A[i]<0:
            print 0
            flag=False
            break
        if A[i]==0:
            l[0]+=1
            if l[0]>=2:
                print 0
                flag=False
                break
        else:
            l[A[i]/2]+=1
            if l[A[i]/2]>=3:
                print 0
                flag=False
                break        
    if flag:
        print 2**((N-1)/2)

Submission status: Wrong Answer

Solution code:
i = int(input())
list_a = list(map(int, input().split()))
dict_ans = {}
for number in list_a:
    try:
        dict_ans[number] += 1
    except KeyError:
        dict_ans[number] = 1
if i % 2 == 0:
    dict_prop = {key:2 for key in [j for j in range(i) if j % 2 == 1]}
    if dict_prop == dict_ans:
        ans = 2 ** (i//2)
    else:
        ans = 0
else:
    dict_prop = {key:2 for key in [j for j in range(i) if j % 2 == 0]}
    dict_prop.update({0:1})
    if dict_prop == dict_ans:
        ans = 2 ** (i // 2)
    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2 == 1:
    for i in ac:
        if i == 0:
            if ac[i] != 1:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print(2 ** (n // 2))
else:
    for i in ac:
        if i == 0:
            if ac[i] != 0:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print(2 ** (n // 2))

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int, input().split()))
ac = collections.Counter(a)
if n % 2 == 1:
    for i in ac:
        if i == 0:
            if ac[i] != 1:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print(2 ** ((n - 1) // 2))
else:
    for i in ac:
        if i == 0:
            if ac[i] != 0:
                print(0)
                exit()
        else:
            if ac[i] != 2:
                print(0)
                exit()
    print(2 ** (n // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
if N % 2:
    if c[0] == 1 and all(c[i] == 2 for i in range(2, N, 2)):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    if all(c[i] == 2 for i in range(1, N, 2)):
        print(2 ** (N // 2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
lis = list(map(int,input().split()))
li = [0 for _ in range(math.ceil(n / 2))]

for i in range(n):
  li[math.floor(lis[i] / 2)] += 1
for i in range(len(li)):
  if n % 2 == 1 and i == 0:
    if li[i] != 1:
      print("0")
      exit()
  else:
    if li[i] != 2:
      print("0")
      exit()
print(2 ** (math.floor(n/2)))

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))
mod = 10**9+7

n = int(input())
a = sorted(f())
if n&1:
    if all([a[i] == i+i%2 for i in range(n)]):
        print(1<<(n//2)%mod)
    else:
        print(0)
else:
    if all([a[i] == i+(i+1)%2 for i in range(n)]):
        print(1<<(n//2)%mod)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
f = lambda: list(map(int,input().split()))
mod = 10**9+7

n = int(input())
a = sorted(f())
if n&1:
    if all([a[i] == i+i%2 for i in range(n)]):
        print(1<<((n-1)//2)%mod)
    else:
        print(0)
else:
    if all([a[i] == i+(i+1)%2 for i in range(n)]):
        print(1<<(n//2)%mod)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = list(map(int, input().split()))
if N%2 == 1:
  if A.count(0) != 1:
    print(0)
    sys.exit()
  i = 1
  while i <= N//2:
    if A.count(2*i) != 2:
      print(0)
      sys.exit()
    i += 1
  j = 0
  ans = 1
  while j <= N//2:
    ans = ans*2
    j += 1
  print(ans)
if N%2 == 0:
  i = 1
  while i <= N//2:
    if A.count(2*i-1) != 2:
      print(0)
      sys.exit()
    i += 1
  j = 0
  ans = 1
  while j < N//2:
    ans = ans*2
    j += 1
  print(ans)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = map(int, raw_input().split())
 
L = [ abs((N-1) - 2*i) for i in range(N)]
 
L.sort()
A.sort()
 
print (2 ** ((N-N%2)/2) ) % (10**9+1) if L == A else 0

Submission status: Wrong Answer

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

L = [ abs((N-1) - 2*i) for i in range(N)]

L.sort()
A.sort()

if L == A and N % 2 == 1:
    print 2 ** ((N-1)/2)

elif N % 2 == 0:
    print 2 ** (N/2)

else:
    print 0

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
is_even=True if n%2==0 else False
dic={}
for i in range(n):
    if a[i] in dic:
        dic[a[i]]+=1
    else:
        dic[a[i]]=1
if is_even:
    for m in dic.values():
        if m!=2:
            print(0)
            exit()
    else:
        print(2**(n//2))
else:
    if a.count(0)!=1:
        print(0)
        exit()
    else:
        dic[0]=2
        for m in dic.values():
            if m!=2:
                print(0)
                exit()
        else:
            print(2**(n//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
flag = 0
check_ans = 0
check_in = 0
x = 1

if n % 2 == 0:
    for i in range(n):
        check_ans += 2 * x - 1
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(0)
            break
        if i % 2 == 1:
            x += 1
    if flag == 0:
        print(2**int(n/2))
else:
    for i in range(1, n):
        check_ans += 2 * x
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(0)
            break
        if i % 2 == 0:
            x += 1
    if flag == 0:
        print(2**int((n-1)/2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
flag = 0
check_ans = 0
check_in = 0
x = 1

if n % 2 == 0:
    for i in range(n):
        check_ans += 2 * x - 1
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(-1)
            break
        if i % 2 == 1:
            x += 1
    if flag == 0:
        print(2**int(n/2))
else:
    for i in range(1, n):
        check_ans += 2 * x
        check_in += a[i]
        if check_ans != check_in:
            flag = 1
            print(-1)
            break
        if i % 2 == 0:
            x += 1
    if flag == 0:
        print(2**int((n-1)/2))

Submission status: Wrong Answer

Solution code:
import collections


def func1(N):
    if N == 0:
        print(0)
    else:
        print(pow(2, int(N / 2)))


def func2(G, N):
    G_list = list(G.values())

    if G_list.count(2) == len(G_list):
        N = N
    else:
        N = 0

    return N


def main():
    N = int(input())
    A = list(map(int, input().split()))
    G = dict(collections.Counter(A))

    if N % 2 == 1:
        if G[0] == 1:
            del G[0]
        else:
            N = 0

    N = func2(G, N)

    func1(N)


main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
A = map(int, input().split())
# N = 5
# A = [2, 4, 4, 0, 2]
mod = 10 ** 9 + 7

cnt = Counter(A)
if N % 2 == 0:
    if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
        print(0)
    else:
        print(2 ** (N // 2))
else:
    if cnt[0] != 1:
        print(0)
    else:
        cnt.pop(0)
        if len(list(filter(lambda c: c != 2, cnt.values()))) != 0:
            print(0)
        else:
            print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
ans=2^10
if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]
  if A==B or A==C:
#    ans=2**(N/2)
    print(int(ans)%(10**9+7))
  else:
    print(0)
else:
  B+=[0]
  C+=[1]
  for i in range(0,int(N/2)):
    B+=[2*i+2,2*i+2]
    C+=[2*i+3,2*i+3]
  if A==B or A==C:
#    ans=2**((N-1)/2)
    print(int(ans)%(10**9+7))
  else: 
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
  for i in range(0,int(N/2)):
    B+=[2*i,2*i]
    C+=[2*i+1,2*i+1]
  if A==B or A==C:
    print(2**N%(10**9+7))
  else:
    print(-1)
else:
  B+=[0]
  C+=[1]
  for i in range(0,int(N/2)):
    B+=[2*i+2,2*i+2]
    C+=[2*i+3,2*i+3]
  if A==B or A==C:
    print(2**(N-1)%(10**9+7))
  else: 
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = [int(e) for e in input().split(' ')]

lst = sorted(lst)

"""
invalid_flg = False
if n % 2 == 1:
    # 奇数
    if not lst.count(0) == 1:
        invalid_flg = True
    for i in range(1, int((n + 1) / 2)):
        if not lst.count(i * 2) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int((((n - 1) / 2) ** 2) % 1000000007))
else:
    # 奇数
    for i in range(1, int((n / 2) + 1)):
        if not lst.count((i * 2) - 1) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int(((n / 2) ** 2) % 1000000007))
"""

valid_list = []
if n % 2 == 1:
    # 奇数
    valid_list.append(0)
    for i in range(1, int((n + 1) / 2)):
        valid_list.append(i * 2)
        valid_list.append(i * 2)
    if lst == valid_list:
        print(int((((n - 1) / 2) ** 2) % 1000000007))
    else:
        print(0)
else:
    for i in range(1, int((n / 2) + 1)):
        valid_list.append((i * 2) - 1)
        valid_list.append((i * 2) - 1)
    if lst == valid_list:
        print(int(((n / 2) ** 2) % 1000000007))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = [int(e) for e in input().split(' ')]

invalid_flg = False
if n % 2 == 1:
    # 奇数
    if not lst.count(0) == 1:
        invalid_flg = True
    for i in range(1, int((n + 1) / 2)):
        if not lst.count(i * 2) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int((((n - 1) / 2) ** 2) % 1000000007))
else:
    # 奇数
    for i in range(1, int((n / 2) + 1)):
        if not lst.count((i * 2) - 1) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int(((n / 2) ** 2) % 1000000007))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = [int(e) for e in input().split(' ')]

invalid_flg = False
if n % 2 == 1:
    # 奇数
    if not lst.count(0) == 1:
        invalid_flg = True
    for i in range(1, int((n + 1) / 2)):
        if not lst.count(i * 2) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int(((n - 1) / 2) ** 2))
else:
    # 奇数
    for i in range(1, int((n / 2) + 1)):
        if not lst.count((i * 2) - 1) == 2:
            invalid_flg = True
    if invalid_flg:
        print(0)
    else:
        print(int((n / 2) ** 2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
length = int(input())
num_list = defaultdict(int)
target = [int(n) for n in input().split(" ")]

for t in target:
    num_list[t] += 1
if length == 1 and target[0] == 0:
    print(1)
elif length % 2 == 1:
    for k,v in num_list.items():
        if k % 2 != 0 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print(2**(length//2))
else:
    for k,v in num_list.items():
        if k % 2 != 1 or (k != 0 and v != 2) or (k == 0 and v != 1):
            print(0)
            break
    else:
        print(2**(length//2))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
length = int(input())
num_list = defaultdict(int)
target = [int(n) for n in input().split(" ")]

for t in target:
    num_list[t] += 1
if length == 1 and target[0] == 0:
    print(1)
elif length % 2 == 1:
    for k,v in num_list.items():
        if k % 2 != 1 or v != 2:
            print(0)
            break
    else:
        print(2**(length//2))
else:
    for k,v in num_list.items():
        if k % 2 != 0 or v != 2:
            print(0)
            break
    else:
        print(2**(length//2))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=map(int,input().split())
def valid():
    b = list(range((n+1)&1, n+1, 2))
    for i in range(len(b)-1, -1, -1):
        b.insert(i, b[i])
    if b[0] == 0:
        b = b[1:]
    return list(sorted(a)) == b
print(2**(n//2) if valid() else 0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
c = 0
if n&1:
    if a[0] == 0:
        del a[0]
        d = Counter(a)
        for i in d.keys():
            if i == 0:
                print 0
                exit(1)
            if i&1:
                print 0
                exit(1)
            if not(i&1):
                if d[i] == 2:
                    c += 1
                if d[i] != 2:
                    print 0
                    exit(1)
    if c == (n-1)//2:
        print 1 << c
if not(n&1):
    d = Counter(a)
    for i in d.keys():
        if i&1:
            if d[i] == 2:
                c +=1
            if d[i] != 2:
                print 0
                exit(1)
        if not(i&1):
            print 0
            exit(1)
    if c == n//2:
        print 1 << c

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
c = 0
if n&1:
    if a[0] == 0:
        del a[0]
        d = Counter(a)
        print d
        for i in d.keys():
            print i
            if i == 0:
                print 0
                exit(1)
            if i&1:
                print 0
                exit(1)
            if not(i&1):
                if d[i] == 2:
                    c += 1
                if d[i] != 2:
                    print "@"
                    print 0
                    exit(1)
    if c == (n-1)//2:
        print 1 << c
        exit(0)
if not(n&1):
    d = Counter(a)
    for i in d.keys():
        if i&1:
            if d[i] == 2:
                c +=1
            if d[i] != 2:
                print 0
                exit(1)
        if not(i&1):
            print 0
            exit(1)
    if c == n//2:
        print 1 << c
        exit(0)

Submission status: Wrong Answer

Solution code:
import sys

cin = sys.stdin
#cin = open("in.txt", "r")

MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N)
if (N%2==1):
    pos[N//2+1]=1
for ai in A:
    if (ai+N)%2==0 or ai>=N or ai<0:
        print(0)
        exit()
    pos[ai]+=1
    if pos[ai]>2:
        print(0)
        exit()
cnt = 1
for i in range(N//2):
    cnt = cnt * 2 % MODULO
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N)
if (N%2==1):
    pos[N//2+1]=1
for ai in A:
    if (ai+N)%2==0:
        print(0)
        exit()
    pos[ai]+=1
    if pos[ai]>2:
        print(0)
        exit()
cnt = 1
for i in range(N//2):
    cnt = cnt * 2 % MODULO
print(cnt)

Submission status: Wrong Answer

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

if N%2 == 0:
    count = [(2 if i%2 == 1 else 0) for i in range(N)]
else:
    count = [(2 if i%2 == 0 else 0) for i in range(N)]
    count[0] = 1

for a in A:
    count[a] -= 1
    if count[a] < 0:
        print(0)
        break
else:
    print(2**(N//2)/(10**9+7))

Submission status: Wrong Answer

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

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        div = 1000000007
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]
        pattern = len([num for num,count in Counter(maybe_list).items() if count != 1])
        if A.sort() ==  maybe_list.sort():
            return (2 ** pattern) % div
        else:
            return 0

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Wrong Answer

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

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        div = 10 ** 9 + 7
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]

        pattern = len([x for x in Counter(maybe_list)])

        for i in A:
            if i < 0  or i >= n:
                raise
            elif i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div


    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Wrong Answer

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

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        if len(A) < 0 or len(A) > n:
            raise

        div = 10 ** 9 + 7
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]
        pattern = len([x for x in Counter(maybe_list)])

        for i in A:
            if i < 0  or i >= n:
                raise
            elif i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Wrong Answer

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

def maybe_check(n,A):
    try:
        if n <= 0 or n > 100000:
            raise

        if len(A) < 0 or len(A) > n:
            raise

        div = 10 ** 9 + 7
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]
        pattern =  len(set([x for x in Counter(maybe_list) if x != 1]))


        for i in A:
            if i < 0  or i >= n:
                raise
            elif i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)

Submission status: Wrong Answer

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

def maybe_check(n,A):
    try:
        if n <= 0 or n >= 10 ** 5:
            raise

        if len(A) < 0 or len(A) > n:
            raise

        div = 10 ** 9 + 7
        maybe_list = [abs(abs(i - n) - ((n -1 ) - abs(i - n))) for i in range(1, n+1) ]
        pattern =  len(set([x for x in maybe_list if maybe_list.count(x) != 1]))

        for i in A:
            if i in maybe_list:
                maybe_list.remove(i)
            else:
                raise

        return (2 ** pattern) % div

    except:
        return 0


_n = int(raw_input())
_A = map(int,raw_input().split())

print maybe_check(_n,_A)