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:
import sys
input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if sum(a)==(n-1)*((n+1)//2):
        print(2**(n//2))
    else:
        print(0)
else:
    if sum(a)==n*n//2:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if sum(a)==(n-1)*((n+1)//2):
        print(2**(n//2))
    else:
        print(0)
else:
    if sum(a)==n*3:
        print(2*(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    A = map(int, input().split())
    count = [0] * N
    ex = [i*2 if N%2!=i%2 else 0 for i in range(N)]
    for a in A:
        count[a] += a
    
    if count == ex:
        return 2**(N//2)
    else:
        return 0
    
if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

ans_0 = False
N = int(input())
l = list(map(int, input().split()))
l_Counter = Counter(l)
if N % 2 == 1:
    if l_Counter[0] != 1:
        ans_0 = True
    else:
        l_Counter[0] = 2
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2:
                cont = True
                break
else:
    for i in l_Counter.items():
        # print(i)
        if i[1] != 2:
            cont = True
            break
#     print(An)
# print(ans_0)
if ans_0:
    print(0)
else:
    print((2 ** (N // 2)) % 1000000007)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
l_Counter = Counter(l)
ans_0 = False
if N % 2 == 1:
    if l_Counter[0] != 1:
        ans_0 = True
    else:
        l_Counter[0] = 2
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2 or i[0] % 2 == 1:
                cont = True
                break
else:
    if l_Counter[0] != 0:
        ans_0 = True
    else:
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2 or i[0] % 2 == 0:
                cont = True
                break
#     print(An)
# print(end_F)
if ans_0:
    print(0)
else:
    print((2 ** (N // 2)) % 1000000007)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
l_Counter = Counter(l)
l_2 = []
ans_0 = False
if N % 2 == 1:
    if l_Counter[0] != 1:
        ans_0 = True
    else:
        l_Counter[0] = 2
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2 and i[0] % 2 == 1:
                cont = True
                break
else:
    if l_Counter[0] != 0:
        ans_0 = True
    else:
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2 and i[0] % 2 == 0:
                cont = True
                break
#     print(An)
# print(end_F)
if ans_0:
    print(0)
else:
    print((2 ** (N // 2)) % 1000000007)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
l_Counter = Counter(l)
l_2 = []
ans_0 = False
if N % 2 == 1:
    if l_Counter[0] != 1:
        ans_0 = True
    else:
        l_Counter[0] = 2
        for i in l_Counter.values():
            if i != 2:
                cont = True
                break
else:
    if l_Counter[0] != 2:
        ans_0 = True
    else:
        for i in l_Counter.values():
            if i != 2:
                cont = True
                break
#     print(An)
# print(end_F)
if ans_0:
    print(0)
else:
    print((2 ** (N // 2)) % 1000000007)

Submission status: Wrong Answer

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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

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

Submission status: Wrong Answer

Solution code:
mod = 1000000007

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

data = [0]*N
for i in a:
  data[i] += 1

cnt = 0
for i in range(1,len(data)):
  if data[i] == 2:
    cnt += 1
  elif data[i] == 0:
    continue
  else:
      print(0)
      exit()
print(pow(2, cnt))

Submission status: Wrong Answer

Solution code:
mod = 1000000007

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

aa = dict.fromkeys(a)
f = 0
cnt = 0
for i in aa:
  if i == 0:
    if a.count(0) == 1:
      continue
    else:
      f = 1
  else:
    if a.count(i) == 2:
      cnt += 1
    else:
      f = 1
if f == 0:
  ans = 1
  for i in range(cnt):
    ans = ans*2 %mod
    print(ans)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = list(map(int,input().split()))
a = set(b)
flag = 0
if n % 2 == 1:
    if all(i % 2 == 0 for i in a) and len(a) == (n-1)//2 +1 and b.count(0) == 1:
        flag = 1
else:
    if all(i % 2 == 1 for i in a) and len(a) == (n-1)//2 + 1:
        flag = 1
print(2**(n//2) if flag==1 else 0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)

    tmp = N - 1
    ans = 1
    for i in range(N//2):
        # print(a[2*i], a[2*i+1], tmp)
        if a[2*i] == tmp and a[2*i+1] == tmp:
            # print("ok")
            ans *= 2
        else:
            print(0)
            return
        tmp -= 2
    
    if N&1:
        if a[N-1] != 0:
            print(0)
            return
    
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
#print(A)
flg=0
if N % 2 == 0:
  for i in range(N//2):
    if A[2*i] == A[2*i+1] == 2*i+1:
      #print(A[i], A[i+1], 2*i+1)
      continue
    else:
      #print(A[i], A[i+1], 2*i+1)
      flg=1
      break
  if flg==1:
    #print('A')
    print(0)
  else:
    #print('B')
    print(2**(N//2))
else:
  if A[0] != 0:
    flg=1
    #print('C')
  else:
    for i in range((N-1)//2):
      if A[2*i+1] == A[2*i+2] == 2*(i+1):
        continue
      else:
        flg=1
        #print('D')
        break
  if flg==1:
    #print('E')
    print(0)
  else:
    #print('F')
    print(2**((N-1)//2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
print(A)
flg=0
if N % 2 == 0:
  for i in range(N//2):
    if A[2*i] == A[2*i+1] == 2*i+1:
      #print(A[i], A[i+1], 2*i+1)
      continue
    else:
      #print(A[i], A[i+1], 2*i+1)
      flg=1
      break
  if flg==1:
    #print('A')
    print(0)
  else:
    #print('B')
    print(2**(N//2))
else:
  if A[0] != 0:
    flg=1
    #print('C')
  else:
    for i in range((N-1)//2):
      if A[2*i+1] == A[2*i+2] == 2*(i+1):
        continue
      else:
        flg=1
        #print('D')
        break
  if flg==1:
    #print('E')
    print(0)
  else:
    #print('F')
    print(2**((N-1)//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
line = [abs(i - (n - i- 1)) for i in range(n)]
if sorted(a) == sorted(line):
    print(2 ** (n // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def index(n:int, a: int):
    if a % 2 == 0:
        i = n // 2 - a // 2
        j = (i + 1) * -1
        return (i, j) if i != n // 2 else (i,)
    else:
        i = (n // 2 - 1) - (a - 1) // 2
        j = (i + 1) * -1
        return (i, j)

n = int(input())
line = [0 for _ in range(n)]
for a in map(int, input().split()):
    for i in index(n, a):
        line[i] += 1
else:
    if n % 2 == 0 and set(line) == {2}:
        print(2 ** (n // 2) % (10 ** 9 + 7))
    elif n % 2 == 1 and set(line) == {1, 2} and line[n//2] == 1:
        print(2 ** ((n - 1) // 2) % (10 ** 9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import*
N=int(input())
if N%2:
 if Counter(map(int,input().split()))==Counter(i//2*2for i in range(1,N+1)):print(2**(N//2))
 else:print(0)
else:
 if Counter(map(int,input().split()))==Counter(i//2*2+1for i in range(N)):print(2**(N//2))
 else:print(0)

Submission status: Wrong Answer

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

def chk(c, n):
    if n % 2:
        if 0 not in c or c[0] != 1:
            return False
        for i in range(2, (n//2)*2+1, 2):
            if i not in c or c[i] != 2:
                return False
    else:
        for i in range(1, n, 2):
            if i not in c or c[i] != 2:
                return False
    return True

if chk(c, N):
    ans = 2 ** (N//2)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

def chk(c, n):
    if n % 2:
        if c[0] != 1:
            return False
        for i in range(2, (n//2)*2+1, 2):
            if c[i] != 2:
                return False
    else:
        for i in range(1, n, 2):
            if c[i] != 2:
                return False
    return True

if chk(c, N):
    ans = 2 ** (N//2)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
s = input().split()
N = n-1
for i in range(n//2+1):
    c = s.count(str(N))
    if N == n//2+1 and c == 1 and N == 0:
        continue
    elif c == 2:
        continue
    else:
        print(0)
        sys.exit()
    N -= 2
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
flag=0
B=[0]*100000
if N%2==1:
    for i in range(N):
        B[A[i]]+=1
    for i in range(N):
        if i==0:
            if B[i]!=1:
                flag=1
        elif i%2==0:
            if B[i]!=2:
                flag=1

if N%2==0:
    for i in range(N):
        B[A[i]]+=1
    for i in range(N):
        if i%2==1:
            if B[i]!=2:
                flag=1


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

Submission status: Wrong Answer

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

for i in range(N//2):
    B.append((N-1) - (i*2))
    B.append((N-1) - (i*2))
if N % 2 == 1:
    B.append(0)
        
A.sort()
B.sort()
if A == B:
    print((2**(N//2-1) * 2) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(N//2):
    B.append((N-1) - (i*2))
    B.append((N-1) - (i*2))
if N % 2 == 1:
    B.append(0)
        
A.sort()
B.sort()
if A == B:
    print(2**(N//2-1) * 2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
count = 0

for i in range(N-1, -1, -2):
    num = A.count(i)
    if i == 0 and num == 0 and N % 2 == 0:
        count += num
    elif i == 0 and num == 1 and N % 2 != 0:
        count += num
    elif num != 2:
        break
    else:
        count += num

if count != N:
    ans = 0
else:
    ans = (N // 2) ** 2 % mod

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ok = True
if N % 2 == 1:
    s = 2
    if A[0] != 0:
        ok = False
        
    for i in range(1, N):
        if A[i] != s:
            ok = False
        if i % 2 == 0: s += 2
else:
    s = 1
    for i in range(N):
        if A[i] != s:
            ok = False
        if i % 2 == 1: s += 2

if ok:
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
ok = True
if N % 2 == 1:
    s = 2
    if A[0] == 0:
        pass
    else:
        ok = False
        
    for i in range(1, N-1):
        if A[i] != s:
            ok = False
        if i % 2 == 0: s += 2
else:
    s = 1
    for i in range(N):
        if A[i] != s:
            ok = False
        if i % 2 == 1: s += 2

if ok:
    print(2 ** (N // 2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if k % 2 != 1:
            ct = 0
            break
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k % 2 != 0:
            ct = 0
            break
        if k == 0 and v != 1:
            ct = 0
            break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
if n == 1 and aaa[0] == 0:
    print(1)
elif ct == 0:
    print(0)
else:
    ans = 2 ** ct
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if k % 2 != 1:
            ct = 0
            break
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k % 2 != 0:
            ct = 0
            break
        if k == 0:
            if v != 1:
                ct = 0
                break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
if ct == 0:
    print(0)
else:
    ans = 2 ** ct
    print(ans % mod)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if k % 2 != 1:
            ct = 0
            break
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k % 2 != 0:
            ct = 0
            break
        if k == 0:
            if v != 1:
                ct = 0
                break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
ans = ct ** 2
print(ans % mod)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if k % 2 != 1:
            ct = 0
            break
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k % 2 != 0:
            ct = 0
            break
        if k == 0:
            if v != 1:
                ct = 0
                break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
ans = ct ** 2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

mod = 10 ** 9 + 7

n = ni()
aaa = na()
c = Counter(aaa)
ct = 0
ans = 0
if n % 2 == 0:
    for k, v in c.items():
        if v == 2:
            ct += 1
        else:
            ct = 0
            break
else:
    for k, v in c.items():
        if k == 0:
            if v != 1:
                ct = 0
                break
        elif v == 2:
            ct += 1
        else:
            ct = 0
            break
ans = ct ** 2
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    A=sorted(list(map(int,input().split())))
    if n%2:
        A.insert(0,0)
        flag=all(A[2*i]==2*i and A[2*i+1]==2*i for i in range(len(A)//2))
        print(2**(n//2) if flag else 0)
    else:
        flag=all(A[2*i]==2*i+1 and A[2*i+1]==2*i+1 for i in range(len(A)//2))
        print(2**(n//2) if flag else 0)

resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int,input().split())))
if N == 1:
    print(1)
    exit()
if N % 2 == 0:
    for i in range(1, N//2+1):
        if A[(i-1)*2] == A[1+(i-1)*2] == 2*i-1:
            pass
        else:
            print(0)
            exit()
    print(2**(N//2))
else:
    if A[0] == 0 and A[1] != 0:
        for i in range(1, N//2+1):
            if A[2*i-1] == A[2*i] == 2*i:
                pass
            else:
                print(0)
                exit()
        print(2**(N//2))
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
flg = True
if N % 2 == 1:
    if A[0] != 0:
        flg = False
    else:
        for i in range(1, N-1, 2):
            if A[i] != A[i+1] or A[i] != A[i-1]+2:
                flg = False
                break
else:
    if A[0] != 1 or A[N-2] != A[N-1]:
        flg = False
    else:
        for i in range(1, N-2, 2):
            if A[i-1] != A[i] or A[i+1] != A[i]+2:
                flg = False
                break
if flg:
    print(2**(N//2))
else:
    print(0)

Submission status: Wrong Answer

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

odd = [k for k in range(N) if k%2 == 1]
even = [j for j in range(N) if j%2 == 0]

dic= {}
for i in A:
    if i in dic:
        dic[i]+= 1
    else:
        dic[i] = 1

flag = 1

if N%2 == 1:
    for m, n in dic.items():
        if m == 0:
            if n != 1:
                flag = 0
                break
        elif m%2 == 1 or n != 2:
            flag = 0
            break
else:
    for m, n in dic.items():
        if m%2==0 or n != 2:
            flag = 0
            break
if flag:
    if N%2 == 0:
        print(2**(N//2))
    else:
        print(2**((N-1)//2))
else:
    print(0)

Submission status: Wrong Answer

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

odd = [k for k in range(N) if k%2 == 1]
even = [j for j in range(N) if j%2 == 0]

dic= {}
for i in A:
    if i in dic:
        dic[i]+= 1
    else:
        dic[i] = 1

flag = 1

if N%2 == 1:
    for m, n in dic.items():
        if m == 0:
            if n != 1:
                flag = 0
                break
        elif m not in even or n != 2:
            flag = 0
            break
else:
    for m, n in dic.items():
        if m not in odd or n != 2:
            flag = 0
            break
if flag:
    if N%2 == 0:
        print(2**(N//2))
    else:
        print(2**((N-1)//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
tf = True
if n % 2 == 1:
    for i in range(1, n):
        a[i] -= i
    ans = int(n//2)
    if ans != sum(a):
        tf = False
else:
    for i in range(n):
        print('i:',i)
        a[i] -= i
    ans = int(n//2)
    if ans != sum(a):
        tf = False
if tf:
    print(2 ** int(n//2) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = sorted([int(_) for _ in input().split()])
if N % 2 == 1:
    if A[0] != 0:
        print(0)
        exit()
    A.pop(0)
    s = 2
else:
    s = 1

ans = 1
MOD = 10 ** 9 + 7
for i in range(0, N // 2):
    v = s + 2 * i
    j = 2 * i
    if A[j] != v and A[j + 1] != v:
        print(0)
        exit()
    ans *= 2
    ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = sorted([int(_) for _ in input().split()])
# a = int(N % 2 != 1)
# flg = int(N % 2 == 1)
# for i in range(N):
#     if A[i] != a:
#         print(0)
#         exit()
#     a += flg * 2
#     flg = (flg + 1) % 2
#
ans = 1
MOD = 10 ^ 9 + 7
for i in range(1, N // 2 + 1):
    ans *= 2
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = sorted([int(_) for _ in input().split()])
a = int(N % 2 != 1)
flg = int(N % 2 == 1)
for i in range(N):
    if A[i] != a:
        print(0)
        exit()
    a += flg * 2
    flg = (flg + 1) % 2

ans = 1
MOD = 10 ^ 9 + 7
for i in range(1, N // 2 + 1):
    ans *= 2
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
from collections import Counter

c = Counter([int(_) for _ in input().split()])
keys = sorted(c.keys())

if len(keys) != N // 2 + int(N % 2 != 0):
    print(0)
    exit()


if N%2==1:
    if c[keys[0]] != 1:
        print(0)
        exit()

a = int(N % 2 != 1)
for k in keys:
    if k != a:
        print(0)
        exit()
    a += 2
ans = 1
MOD = 10 ^ 9 + 7
for i in range(1, N // 2 + 1):
    ans *= 2
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
from collections import Counter

c = Counter([int(_) for _ in input().split()])
keys = sorted(c.keys())

if len(keys) != N // 2 + int(N % 2 != 0):
    print(0)
    exit()


if N%2==0:
    if c[keys[0]] != 1:
        print(0)
        exit()

a = int(N % 2 != 1)
for k in keys:
    if k != a:
        print(0)
        exit()
    a += 2
ans = 1
MOD = 10 ^ 9 + 7
for i in range(1, N // 2 + 1):
    ans *= 2
    ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))

Devide_N=10**9+7
Rem_2_32_DN=(2**32)%Devide_N

if N%2==1:
  if A.count(0)!=1:
    print(0)
  else:
    for ch_n in range(1,(N-1)//2+1):
      if A.count(ch_n*2)!=2:
        break
      else:
        A.remove(ch_n*2)
        A.remove(ch_n*2)
    else:
      #exp=(N-1)//2
      
      #exp_quotient_32=exp//32
      #exp_rem_32=exp%32
      #Rem_ans_Devide_N=1
      #for _ in range(exp_quotient_32):
      #  Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
        
      #print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
      sys.exit()
    print(0)
else:
  for ch_n in range(1,N//2+1):
    if A.count(ch_n*2-1)!=2:
      break
    else:
      A.remove(ch_n*2-1)
      A.remove(ch_n*2-1)
  else:
    #exp=N//2
    
    #exp_quotient_32=exp//32
    #exp_rem_32=exp%32
    #Rem_ans_Devide_N=1
    #for _ in range(exp_quotient_32):
    #  Rem_ans_Devide_N=(Rem_ans_Devide_N*Rem_2_32_DN)%Devide_N
      
    #print((Rem_ans_Devide_N*2**(exp_rem_32))%Devide_N)
    sys.exit()
  print(0)

Submission status: Wrong Answer

Solution code:
import collections
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)

ans = 1
for key, value in c.items():
    if key == 0:
        if n % 2 == 1 and value != 1:
            print(0)
            exit()
        else:
            continue
    elif value == 2:
        ans *= 2
        ans %= MOD
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
alist = list(map(int, input().split()))
len_alist = len(alist)

if len_alist % 2 == 0:
  nums = [2 for _ in range(n//2)]
  for a in alist:
    nums[(a-1)//2] -= 1
    if nums[(a-1)//2] < 0:
      break
  if all(num == 0 for num in nums):
    print(2**(n//2))
  else:
    print(0)
else:
  nums = [1] + [2 for _ in range((n-1)//2)]
  for a in alist:
    nums[(a)//2] -= 1
    if nums[(a)//2] < 0:
      break
  if all(num == 0 for num in nums):
    print(2**((n-1)//2))
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
arr = [abs(i - (n-i-1)) for i in range(n)]
ans = 2**(n//2) if Counter(a) == Counter(arr) else 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc050/tasks/arc066_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))
    al.sort()

    if len(al) % 2 == 1:  # odd
        if al[0] != 0:
            print(0)
            return
        al = al[1:]

    for i in range(0, len(al), 2):
        if al[i] != al[i+1]:
            print(0)
            return

    print(2 ** (len(al) // 2) % 1000000009)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc050/tasks/arc066_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    al = list(map(int, input().split()))
    al.sort()

    if len(al) % 2 == 1:  # odd
        if al[0] != 0:
            print(0)
            return
        al = al[1:]

    for i in range(0, len(al), 2):
        if al[i] != al[i+1]:
            print(0)
            return

    print(2 ** (len(al) // 2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
A = LI()

"""
5
2 4 4 0 2

2なら、
xOxxx
xxxOx
の2通りしかない
N=9なら
xxxOxxxxx
xxxxxOxxx
の2通りしかない
4なら
Oxxxxと
xxxxO
しかない
これらをもとに確かめていく


Nが奇数の時
3
2 0 2
とすると成り立つ
4のとき
3 1 1 3
まずこれでできない場合をはじける

計算するまでもないのか。

2 4 4 0 2なら
前か後ろか、前か後ろかをかけるだけなので4

"""
if N == 1:
    if A[0] == 0:
        print(1)
    else:
        print(0)
    exit()

A.sort()

if N % 2 == 0:
    correct = list(range(1,N+1, 2))
    correct = correct + correct
    correct.sort()
else:
    # 奇数時
    correct = list(range(0, N+1, 2))
    correct = correct + correct
    correct.sort()
    correct = correct[1:]
if correct == A:
    ans = 2**(N//2)
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
A = list(map(int,input().split(' ')))
C = collections.Counter(A)
L = C.most_common()

if N % 2 == 0:
  for i, j in L:
    if j == 2:
      pass
    else:
      print(0)
      exit()
else:
   for i, j in L:
    if j == 2:
      pass
    else:
      if i == 0:
        pass
      else:
        print(0)
        exit()
print(int(2**(N//2)))