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:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    A = list(input().split())
    s_num = N -1
    A.sort()
    if(N==1 and A[0]!=str(0)):
        ans = 0
    else:
        ans = 2**(N//2) % p
    if(N%2 == 1):
        s = 2
        c= A.pop(0)
        if c != 0:
            print(0)
            exit()
    else:
        s = 1
    for i in range(N//2):
        j = i*2
        if(A[j] == A[j+1] and A[j+1] == str(s+j) and A[j] == str(s+j)):
            continue
        else:
            ans = 0
            break        

    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10

    # mod用
    p=10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    A = list(input().split())
    s_num = N -1
    A.sort()
    if(N==1 and A[0]!=str(0)):
        ans = 0
    else:
        ans = 2**(N//2) % p
    if(N%2 == 1):
        s = 2
        A.pop(0)
    else:
        s = 1
    for i in range(N//2):
        j = i*2
        if(A[j] == A[j+1] and A[j+1] == str(s+j) and A[j] == str(s+j)):
            continue
        else:
            ans = 0
            break        

    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    A = list(input().split())
    s_num = N -1
    A.sort()
    if(N==1 and A[0]!=str(0)):
        ans = 0
    else:
        ans = 2**(N//2)
    if(N%2 == 1):
        s = 2
        A.pop(0)
    else:
        s = 1
    for i in range(N//2):
        j = i*2
        if(A[j] == A[j+1] and A[j+1] == str(s+j) and A[j] == str(s+j)):
            continue
        else:
            ans = 0
            break        

    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import bisect

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    N = int(input().rstrip())
    # A = list(int(_) for _ in input().split())
    A = list(input().split())
    s_num = N -1
    A.sort()
    ans = 2**(N//2)
    if(N%2 == 1):
        s = 2
        A.pop(0)
    else:
        s = 1
    for i in range(N//2):
        j = i*2
        if(A[j] == A[j+1] and A[j+1] == str(s+j) and A[j] == str(s+j)):
            continue
        else:
            ans = 0
            break        
    # while s_num > 0:
    #     count = A.count(str(s_num))
    #     if(s_num != 0 and count != 2):
    #         ans = 0 
    #         break
    #     elif(s_num == 0 and count !=1):
    #         ans = 0 
    #         break
    #     s_num -= 2
    
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A.sort()
ok = False
if A[0] == 0 and N % 2 == 1:
    ok = True
    for i in range(N):
        if A[i] != (i + 1) // 2 * 2:
            ok = False
            break
elif A[0] == 1 and N % 2 == 0:
    ok = True
    for i in range(N):
        if A[i] != i // 2 * 2 + 1:
            ok = False

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

Submission status: Wrong Answer

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

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

a.sort()

can = True

if a[0] == 0:
    for i in range(1,n):
        if i % 2 != 1:
            if a[i] != i:
                can = False
                break
        else:
            if a[i] != i + 1:
                can = False
                break
    if can:
        print(2 ** int((n-1)/2))
    else:
        print(0)
elif a[0] == 1:
    for i in range(0,n):
        if i % 2 != 1:
            if a[i] != i + 1:
                can = False
                break
        else:
            if a[i] != i:
                can = False
                break
    if can:
        print(2 ** int(n/2))
    else:
        print(0)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
stack=[0]*(10**5+1)
p=10**9+7
for i in a:
  stack[i]+=1
if n%2==0:
  for j in range(1,n+1,2):
    if stack[j]!=2:
      print(0)
      exit()
  print(pow(2,n//2,p))
  exit()
flag=True
for j in range(0,n+1,2):
  if stack[j]!=2:
    if flag and stack[j]==1:
      flag=False
      continue
    print(0)
    exit()
  print(pow(2,n//2,p))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
stack=[0]*(10**5+1)
p=10**9+7
for i in a:
  stack[i]+=1
if n%2==0:
  for j in range(1,n+1,2):
    if stack[j]!=1:
      print(0)
      exit()
  print(pow(2,n//2,p))
  exit()
for j in range(0,n+1,2):
  if stack[j]!=1:
    print(0)
    exit()
  print(pow(2,n//2,p))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
A = inpl()

ans_l = []
if N % 2 == 0:
    for i in range(1, N):
        if i % 2 == 1:
            ans_l.append(i)
            ans_l.append(i)
else:
    for i in range(1, N):
        if i % 2 == 0:
            ans_l.append(i)
            ans_l.append(i)
    ans_l.append(0)

A.sort()
ans_l.sort()

if A == ans_l:
    print((2**(N//2))%(int(10e9)+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
A = inpl()

ans_l = []
if N % 2 == 0:
    for i in range(1, N):
        if i % 2 == 1:
            ans_l.append(i)
            ans_l.append(i)
else:
    for i in range(1, N):
        if i % 2 == 0:
            ans_l.append(i)
            ans_l.append(i)
    ans_l.append(0)

A.sort()
ans_l.sort()

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

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
INF = float("inf")

N = int(input())
A = inpl()

c = Counter(A)
if N%2 == 1:
    flag = True
    if 0 not in c or c[0] != 1: flag = False
    for i in range(1, N):
        if i % 2 == 0:
            if i not in c or c[i] != 2: flag = False
        else:
            if i in c: flag = False
    if flag:
        print(2**((N-1)//2))
    else:
        print(0)
else:
    flag = True
    if 0 in c: flag = False
    for i in range(1, N):
        if i % 2 == 0:
            if i in c: flag = False
        else:
            if i not in c or c[i] != 2: flag = False
    if flag:
        print(2**(N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
mod = 10**9 + 7
ans = 1
if N == 1:
    if A[0] == 0:
        print(ans)
        sys.exit()
    else:
        print(0)
        sys.exit()
if N%2 == 0:
    for i in range(N//2):
        if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
            print(0)
            sys.exit()
        else:
            ans *= 2
    print(ans)
else:
    if A.pop(0) != 0:
        print(0)
        sys.exit()
    else:
        for i in range((N-1)//2):
            if A[2*i] != 2*i+2 or A[2*i+1] != 2*i+2:
                print(0)
                sys.exit()
            else:
                ans *= 2
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
mod = 10**9 + 7
ans = 1
if N%2 == 0:
    for i in range(N//2):
        if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
            print(0)
            sys.exit()
        else:
            ans *= 2
    print(ans)
else:
    if A.pop(0) != 0:
        print(0)
        sys.exit()
    else:
        for i in range((N-1)//2):
            if A[2*i] != 2*i+2 or A[2*i+1] != 2*i+2:
                print(0)
                sys.exit()
            else:
                ans *= 2
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

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

X.sort()
ans=(2**(n//2))%(10**9+7)

for a,x in zip(A,X):
    if a!=x:
        ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n=int(input())

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

X=collections.Counter(A)


if n%2==0:
    flag=True
    for k,v in X.items():
        if v!=2:
            flag=False
            break
        if k not in [int(i) for i in range(1,n+1,2)]:
            flag=False
            break
    if flag:
        print((2**(n//2))%(10**9+7))
    else:
        print(0)
else:
    flag=True
    if X['0']!=1:
        flag=False
    for k,v in X.items():
        if v!=2:
            flag=False
            break
        if k not in [int(i) for i in range(0,n+1,2)]:
            flag=False
            break
    if flag:
        print((2**(n//2))%(10**9+7))
    else:
        print(0)

Submission status: Wrong Answer

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

def f():
    global a
    cnt = 1 + (n%2)
    if n%2 == 1:
        if a[0] != 0:
            return 0
        a = a[1:]

    # check
    for i in range(len(a)):
        if a[i] != cnt:
            return 0

        if i%2 == 1:
            cnt+=2

    return 2**(n//2)

print(f())

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
*pr, = map(int,input().split())
#print(pr)
d = collections.Counter(pr)
#print(d)
mod = 10**9+7
if n % 2 != 0:
  if d[0] != 1:
    print(0)
    exit()
  else:
    for k, v in d.items():
      if k != 0 and v != 2:
        print(0)
        exit()
      elif k%2 != 0:
        print(0)
        exit()
    print(((len(d)-1)**2)%mod)
else:
  for ky,vl in d.items():
    if ky == 0:
      print(0)
      exit()
    elif ky%2 == 0:
      print(0)
      exit()
    elif vl != 2:
      print(0)
      exit()
  print((len(d)**2)%mod)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
*pr, = map(int,input().split())
#print(pr)
d = collections.Counter(pr)
#print(d)
if n % 2 != 0:
  if d[0] != 1:
    print(0)
    exit()
  else:
    for k, v in d.items():
      if k != 0 and v != 2:
        print(0)
        exit()
      elif k%2 != 0:
        print(0)
        exit()
    print((len(d)-1)**2)
else:
  for ky,vl in d.items():
    if ky == 0:
      print(0)
      exit()
    elif ky%2 == 0:
      print(0)
      exit()
    elif vl != 2:
      print(0)
      exit()
  print(len(d)**2)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
*pr, = map(int,input().split())
#print(pr)
d = collections.Counter(pr)
#print(d)
if n % 2 != 0:
  if d[0] != 1:
    print(0)
    exit()
  else:
    for k, v in d.items():
      if k != 0 and v != 2:
        print(0)
        exit()
    print((len(d)-1)**2)
else:
  for ky,vl in d.items():
    if ky == 0:
      print(0)
      exit()
    elif vl != 2:
      print(0)
      exit()
  print(len(d)**2)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ok = [0]*(n)
flag = 0
for a in A:
	ok[a] += 1
if n%2 == 1:
	if ok[0] == 1 and set(ok[1::2]) == {0} and set(ok[2::2]) == {2}:
		flag = 1
else:
	if set(ok[::2]) == {0} and set(ok[1::2]) == {2}:
		flag = 1
if flag:
	print((2**(n//2))%(10**9+7))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ok = [0]*(n)
flag = 0
for a in A:
	ok[a] += 1
if n%2 == 1:
	if ok[0] == 1 and set(ok[1::2]) == {0} and set(ok[2::2]) == {2}:
		flag = 1
else:
	if set(ok[::2]) == {0} and set(ok[1::2]) == {2}:
		flag = 1
if flag:
	print(2**(n//2))
else:
	print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ok = [0]*(n)
for a in A:
	ok[a] += 1
if n%2 == 1:
	if ok[0] == 1 and set(ok[1::2]) == {0} and set(ok[2::2]) == {2}:
		print(2**(n//2))
	else:
		print(0)
else:
	if set(ok[::2]) == {0} and set(ok[1::2]) == {2}:
		print(2**(n//2))
	else:
		print(0)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python 
# -*- coding: utf-8 -*- 
#===============================================================================
# Date created  : 2019-03-26T14:51:38+09:00
# Date modified : 2019-03-26T15:03:21+09:00
# Author        : awk
# Description   : unanswered
#===============================================================================
N = int(input())
L = list(map(int,input().split()))
if N % 2 == 0:
    correct = []
    for i in range(N // 2):
        correct.append(i*2 + 1)
        correct.append(i*2 + 1)

    if sorted(L) == sorted(correct):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    correct = [0]
    for i in range(N // 2):
        correct.append((i+1)*2)
        correct.append((i+1)*2)
    if sorted(L) == sorted(correct):
        print(2 ** (N // 2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/python 
# -*- coding: utf-8 -*- 
#===============================================================================
# Date created  : 2019-03-26T14:51:38+09:00
# Date modified : 2019-03-26T15:00:33+09:00
# Author        : awk
# Description   : unanswered
#===============================================================================
import collections as coll
N = int(input())
L = list(map(int,input().split()))
if N % 2 == 0:
    correct = []
    for i in range(N // 2):
        correct.append(i*2 + 1)
        correct.append(i*2 + 1)

    if coll.Counter(L) == coll.Counter(correct):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    correct = [0]
    for i in range(N // 2):
        correct.append((i+1)*2)
        correct.append((i+1)*2)
    if coll.Counter(L) == coll.Counter(correct):
        print(2 ** (N // 2))
    else:
        print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n % 2 == 0:
  k = 1
  l = 0
else:
  k = 0
  l = 1 


flag = True 
for i,s in enumerate(sa):
  if ((i+l)//2)*2+k != s:
    flag = False
if flag:
  print(2**(n//2))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = pow(2, N // 2)
# 0*1 2*2 4*2 2^N/2*2
check = [0 for p in range(0, N // 2 + N % 2)]
for o in A:
    check[o // 2] += 1

for q in range(0, N // 2 + N % 2):
    if q == 0 & N % 2 == 1:
        if check[q] != 1:
            ans = 0
            break
    else:
        if check[q] != 2:
            ans = 0
            break
print(ans % (pow(10, 9) + 7))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5*1)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if all(list(map(lambda x:x==2,b[1:n+1:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    if all(list(map(lambda x:x == 2,b[2:n+1:2]))) and b[0] == 1:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if all(list(map(lambda x:x==2,b[1:n+1:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    if all(list(map(lambda x:x == 2,b[2:n+1:2]))) and b[0] == 1:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if sum(b[:n+1:2]) == 0 and all(list(map(lambda x:x==2,b[1:n+1:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    if sum(b[1:n+1:2]) == 0 and all(list(map(lambda x:x == 2,b[2:n+1:2]))) and b[0] == 1:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if sum(b[:n:2]) == 0 and all(list(map(lambda x:x==2,b[1:n:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    if sum(b[1:n:2]) == 0 and all(list(map(lambda x:x == 2,b[2:n:2]))) and b[0] == 1:
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if sum(b[:n:2]) == 0 and all(list(map(lambda x:x==2,b[1:n:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    if sum(b[1:n:2]) == 0 and all(list(map(lambda x:x == 2,b[2:n:2]))):
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

b = [0 for i in range(10**5)]

for i in range(n):
    b[a[i]] += 1
if n % 2 == 0:
    if sum(b[:n:2]) == 0 and all(list(map(lambda x:x==2,b[1:n:2]))):
        print(2**(n//2))
    else:
        print(0)

else:
    print(b[1:n:2],list(map(lambda x:x == 2,b[2:n:2])))
    if sum(b[1:n:2]) == 0 and all(list(map(lambda x:x == 2,b[2:n:2]))):
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
#ABC050C
N=int(input())
A=list(map(int,input().split()))
if N%2==1:
    if A.count(0)!=1:
        print(0)
        exit()
B=[0 for i in range(N//2)]
for a in A:
    if a == 0:
        continue
    elif a%2==(N+1)%2:
        B[a//2-N%2]+=1
    else:
        print(0)
        exit()
if B.count(2)==len(B):
    print(2**(N//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#ABC050C
N=int(input())
A=list(map(int,input().split()))
if N%2==1:
    if A.count(0)!=1:
        print(0)
        exit()
B=[0 for i in range(N//2)]
for a in A:
    if a!= 0:
        B[a//2-N%2]+=1
if B.count(2)==len(B):
    print(2**(N//2))
else:
    print(0)

Submission status: Wrong Answer

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

A.sort()
if len(A) % 2 == 1:
  odd = True
else:
  odd = False

value = 1

if odd:
  for i in range(len(A)//2):
    if A[2*i+1] == A[2*i+2] and A[2*i+1] == 2*i+2:
      value *= 2
    else:
      value *= 0
      break
  if A[0] != 0:
    value *= 0
else:
  for i in range(len(A)//2):
    if A[2*i] == A[2*i+1] and A[2*i] == 2*i+1:
      value *= 2
    else:
      value *= 0

print(value)

Submission status: Wrong Answer

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

if N % 2 != 0:
    if aList.count(0) != 1:
        print(0)
        quit()
    aList.remove(0)
    aList.sort()
    for x,y in zip(aList[0::2], aList[1::2]):
        if x != y:
            print(0)
            quit()
        elif x % 2 != 0:
            print(0)
            quit()
else:
    if 0 in aList:
        print(0)
        quit()

    aList.sort()
    for x,y in zip(aList[0::2], aList[1::2]):
        if x != y:
            print(0)
            quit()
        elif x % 2 != 1:
            print(0)
            quit()

print(((len(aList)//2)%(10**9 + 7))**2)

Submission status: Wrong Answer

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

if N % 2 != 0:
    if aList.count(0) != 1:
        print(0)
        quit()
    aList.remove(0)
    aList.sort()
    for x,y in zip(aList[0::2], aList[1::2]):
        if x != y:
            print(0)
            quit()
        elif x % 2 != 0:
            print(0)
            quit()
else:
    if 0 in aList:
        print(0)
        quit()

    aList.sort()
    for x,y in zip(aList[0::2], aList[1::2]):
        if x != y:
            print(0)
            quit()
        elif x % 2 != 1:
            print(0)
            quit()

print((len(aList)//2)**2 % (7+10**9))

Submission status: Wrong Answer

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

count = 0

if N % 2 != 0:
    if aList.count(0) != 1:
        print(0)
        quit()
    aList.remove(0)

p = list(set(aList))
for x in p:
    if aList.count(x) != 2:
        print(0)
        quit()

print(len(p)**2 % (7+10**9))

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
A = Counter([int(i) for i in input().split()])

ans = 0
if n % 2 == 1:
    for k, v in A.items():
        if k == 0 and v != 1:
            ans = 0
            break
        elif v >= 3:
            ans = 0
            break
        elif v == 2:
            ans += 1
else:
    for k, v in A.items():
        if v != 2:
            ans = 0
            break
        else:
            ans += 1
            
if n == 1:
    if A[0] == 0:
        print(1)
    else:
        print(0)
elif ans == 0:
    print(0)
else:
    print(2 ** ans % mod)

Submission status: Wrong Answer

Solution code:
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
A = Counter([int(i) for i in input().split()])

ans = 0
if n % 2 == 1:
    for k, v in A.items():
        if k == 0 and v != 1:
            ans = 0
            break
        elif v >= 3:
            ans = 0
            break
        elif v == 2:
            ans += 1
else:
    for k, v in A.items():
        if v != 2:
            ans = 0
            break
        else:
            ans += 1
            
if ans == 0:
    print(0)
else:
    print(2 ** ans % mod)

Submission status: Wrong Answer

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

ans = 0
if n % 2 == 1:
    for k, v in A.items():
        if k == 0 and v != 1:
            ans = 0
            break
        elif v >= 3:
            ans = 0
            break
        elif v == 2:
            ans += 1
else:
    for k, v in A.items():
        if v != 2:
            ans = 0
            break
        else:
            ans += 1
            
if ans == 0:
    print(0)
else:
    print(2 ** ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    b=sorted(a)
    i=0
    while i<len(b):
        if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
            print(0)
            exit()
        i+=2
    print((2**(len(b)//2))%(10**9+7))
else:
    b=sorted(a)
    if b[0]!=0:
        print(0)
        exit()
    if len(b)>1:
        if b[1]==0:
            print(0)
            exit()
    else:
        i=1
        while i<len(b):
            if not (b[i]==b[i+1] or b[i+2]==b[i]+2):
                print(0)
                exit()
            i+=2
        print(2**(len(b)//2)%(10**9+7))

Submission status: Wrong Answer

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

a = sorted(a)
if n%2 ==1:
  flag = True
  if a[0]!=0:
    flag = False
  for i in range(1,n,2):
    if not(a[i]==a[i+1] and a[i-1]!=a[i]):
      flag =False
  print(2**(n//2) if flag else 0)

else:
  flag = True
  if not(a[0]==a[1] and a[0]==1):
    flag = False
  for i in range(2,n,2):
    if not(a[i]==a[i+1] and a[i-1]!=a[i]):
      flag =False
  print(2**(n//2) if flag else 0)

Submission status: Wrong Answer

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