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
import copy
from collections import deque
stdin = sys.stdin

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a_list = na()

c = {abs((n-1-i)-i): 0 for i in range(n//2 + 1)}

for a in a_list:
    if a not in c or c[a]==2:
        print(0)
        exit(0)
    c[a] += 1

cnt = 1
for k,v in c.items():
    if v==2 or k==0:
        cnt *= v
    else:
        print(0)
        exit(0)

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = sorted(map(int, input().split()))
MOD = 10 ** 9 + 7
if n % 2:
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, n-1, 2):
        if A[i] != A[i+1]:
            print(0)
            exit()
else:
    for i in range(n-1, 2):
        if A[i] != A[i+1]:
            print(0)
            exit()
M = (max(A) + 1) // 2
print(2 ** M % MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = True

    odd = n % 2

    if odd:
        if 0 in c.keys():
            c[0] += n % 2
        for i in range(0, n, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break
    else:
        for i in range(1, n, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break

    if ans:
        print(2 ** (n // 2))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = True


    odd = n % 2

    if odd:
        if 0 in c.keys():
            c[0] += n % 2
        for i in range(0, n + 1, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break
    else:
        for i in range(1, n + 1, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break

    if ans:
        print(2 ** (n // 2))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = True


    odd = n % 2

    if odd:
        c[0] += n % 2
        for i in range(0, n + 1, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break
    else:
        for i in range(1, n + 1, 2):
            if i not in c.keys():
                ans = False
                break
            if c[i] != 2:
                ans = False
                break

    if ans:
        print(2 ** (n // 2))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    ans = True


    odd = n % 2

    if odd:
        c[0] += n % 2
        for i in range(0, n + 1, 2):
            if c[i] != 2:
                ans = False
                break
    else:
        for i in range(1, n + 1, 2):
            if c[i] != 2:
                ans = False
                break

    if ans:
        print(2 ** (n // 2))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

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

if len(arr) % 2 == 0:
    if 0 in arr:
        print(0)
        sys.exit()
else:
    if arr.count(0) != 1:
        print(0)
        sys.exit()
    else:
        arr.remove(0)

cnt = Counter(arr)

values = list(cnt.values())

if values.count(2) != len(values):
    print(0)
    sys.exit()

print(2**(n // 2))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from functools import reduce
from operator import mul

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

if arr.count(0) > 1:
    print(0)
    sys.exit()

if len(arr) % 2 == 0 and arr.count(0) > 0:
    print(0)
    sys.exit()

cnt = Counter(arr)

li = list(cnt.values())

if li.count(2) != n // 2:
    print(0)
    sys.exit()

if not all([x <= 2 for x in li]):
    print(0)
    sys.exit(0)

print(reduce(mul, li))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import*
n, *a = map(int, open(0).read().split())
c = Counter(a)
if n%2:
    if c.get(0, 0) != 1 or any(c.get(i, 0) != 2 for i in range(2, n, 2)):
        exit(print(0))
    print(2 ** (n // 2))
else:
    if any(c.get(i, 0) != 2 for i in range(1, n, 2)):
        exit(print(0))
    print(2 ** (n // 2))

Submission status: Wrong Answer

Solution code:
n = int(input())
L = list(map(int,input().split()))
from collections import Counter
L = Counter(L)
#print(L)
cnt_2 = 0
cnt_0 = 0
else1 = 0
for k,v in L.items():
    if v == 2:
        cnt_2 +=1
    elif k == 0 :
        cnt_0 +=v
    else:
        else1 +=1
#print(cnt_2,cnt_0)
if else1 != 0:
    print(0)
elif n%2 == 1 and cnt_0 == 1:
    print(2**cnt_2)
elif n%2 == 1 and cnt_0 != 1:
    print(0)
elif n%2 == 0 and cnt_0 != 0:
    print(0)
elif n%2 == 0 and cnt_0 == 0:
    print(2**cnt_2)

Submission status: Wrong Answer

Solution code:
import collections

MOD = pow(10, 9)+7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Acount = collections.Counter(A)
    Aitem = list(zip(*Acount.items()))
    ans = 1
    flag = True
    if N%2 == 0:
        if set(Aitem[1]) != {2}:
            flag = False
        for a in Aitem[0]:
            if a%2 == 0:
                flag = False
                break
    else:
        if set(Aitem[1]) != {1, 2}:
            flag = False
        if Acount[0] != 1:
            flag = False
        for a in Aitem[0]:
            if a%2 == 1:
                flag = False
                break
    if flag:
        for a in Aitem[1]:
            ans = (ans * a)%MOD
    else:
        ans = 0
    print(ans%MOD)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
dic = dict(Counter(A))
for k,v in dic.items():
    if n%2==0:
        if v!=2 or k==0:
            print(0)
            break
    else:
        if k!=0 and v!=2:
            print(0)
            break
        elif k==0 and v!=1:
            print(0)
            break
else:
    if n%2==0:
        print(2**len(dic))
    else:
        print(2**(len(dic)-1))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

cnt = defaultdict(int)
for i in range(n):
    cnt[a[i]//2] += 1

ans = 1
for i, v in cnt.items():
    if v % 2 == 1 and i != 0:
        print(0)
        exit()
    else:
        ans *= v

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    from sys import stdin
    input = lambda : stdin.readline().rstrip()
    N = int(input())
    diff = [0] * N
    A = map(int,input().split())
    for a in A:
        diff[a] += 1
    r = N % 2

    if r == 1 and diff[0] != 1:
        print(0)
        return
    ans = 0
    for i in range(r,N,2):
        if not diff[i] == 0:
            print(0)
            return
    for i in range(r+1,N,2):
        if not diff[i] == 2:
            print(0)
            return
    print(pow(N//2,2,10**9+7))
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter


P = 10 ** 9 + 7

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

def solve():
  counter = Counter(numbers)
  
  if N % 2 == 0:
    if all([counter[i] == 2 for i in range(1, N) if N % 2 != 0]):
      return (2 ** (N // 2)) % P
    else:
      return 0
  else:
    if all([counter[i] == 2 for i in range(1, N) if N % 2 == 0]) and counter[0] == 1:
      return (2 ** (N // 2)) % P
    else:
      return 0
    
print(solve())

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
n, *lst = map(int, sys.stdin.read().split())
lst = sorted(Counter(lst).items())
l = len(lst)
mod = 10 ** 9 + 7
if n % 2:
  for i in range(l):
    if not i:
      if lst[i][0] or lst[i][1] != 1:
        print(0)
        quit()
    if lst[i][0] != i * 2 or lst[i][1] != 2:
      print(0)
      quit()
else:
  for i in range(l):
    if lst[i][0] != i * 2 + 1 or lst[i][1] != 2:
      print(0)
      quit()
print((1 << (n >> 1)) % mod)

Submission status: Wrong Answer

Solution code:
import sys

n, *lst = map(int, sys.stdin.read().split())
lst.sort()
mod = n % 2
if mod:
  if lst[0]:
    print(0)
    quit()
  for i in range(1, n):
    if lst[i] != ((i + 1) >> 1) << 1:
      print(0)
      quit()
else:
  for i in range(n):
    if lst[i] != ((i  >> 1) << 1) + 1:
      print(0)
      quit()
print(1 << (n >> 1))

Submission status: Wrong Answer

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
ar.sort()
b = ar.count(0) 
if b >= 2:
    print(0)
    exit()
br = ar[b:a]
for i in range(0,len(br)-2,2):
    if ar[i] + 2 != ar[i+2]:
        print(0)
        exit()
print(2 ** (len(br) // 2))

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    DIV = 10**9+7
    if n%2==1:
        bb = [0]
        for i in range(2,n,2):
            bb.append(i)
            bb.append(i)
    else:
        bb = []
        for i in range(1,n,2):
            bb.append(i)
            bb.append(i)
    if aa != bb:
        print(0)
        return None

    if n==1: print(1)
    elif n==2: print(2)
    elif n==3: print(2)
    else:
        print(((n//2)**2)%DIV)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    DIV = 10**9+7
    if n%2==1:
        bb = [0]
        for i in range(2,n,2):
            bb.append(i)
            bb.append(i)
    else:
        bb = []
        for i in range(1,n,2):
            bb.append(i)
            bb.append(i)
    if aa == bb:
        print(((len(aa)//2)**2)%DIV)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
import itertools as it
import functools as ft
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#
def main():
    n = II()
    aa = MII()
    DIV = 10**9+7
    c = Counter(aa)
    vs = c.values()
    ks = c.keys()
    if n%2==0:
        if set(vs) != {2}:
            print(0)
            return None
        print((len(ks)**2)%DIV)
    else:
        if set(vs) == {1,2} and c[0] == 1:
           print(((len(ks)-1)**2)%DIV)
        else:
            print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

counter = Counter(A)
if N % 2 == 1:
    if 0 not in counter or counter[0] != 1:
        print(0)
        sys.exit()
       
if len(counter) != (N+1) // 2:
    print(0)
    sys.exit()

for (pos, count) in counter.items():
    if N % 2 == 1 and pos % 2 == 1:
        print(0)
        sys.exit()
    elif N % 2 == 0 and pos % 2 == 0:
        print(0)
        sys.exit()
        
    if pos == 0:
        if count > 1:
            print(0)
            sys.exit()
    elif count != 2:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

counter = Counter(A)
for (pos, count) in counter.items():
    if pos == 0:
        if count > 1:
            print(0)
            sys.exit()
    elif count != 2:
        print(0)
        sys.exit()

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

Submission status: Wrong Answer

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

if a[0]==0:
    a.remove(0)
    sta=0
else:
    sta=1
for i in range(1,len(a),2):
    if a[i]!=a[i-1] or a[i]%2!=sta or a[i]!=i+1-sta:
        print(0)
        exit()
ans=2**(len(a)//2)
print(ans)

Submission status: Wrong Answer

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

if a[0]==0:
    a.remove(0)
    sta=0
else:
    sta=1
for i in range(1,len(a),2):
    if a[i]!=a[i-1] or a[i]%2!=sta or a[i]!=2*(i+1)-sta:
        print(0)
        exit()
ans=2**(len(a)//2)
print(ans)

Submission status: Wrong Answer

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

if a[0]==0:
    a.remove(0)
    sta=0
else:
    sta=1
for i in range(1,len(a),2):
    if a[i]!=a[i-1] or a[i]%2!=sta:
        print(0)
        exit()
ans=2**(len(a)//2)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

p=10**9+7
N=int(input())
A = list(map(int,input().split()))
  
c=Counter(A)
d=dict(c)
if c.most_common()[0][1]>2:
  ans = 0
else:
  if 0 in d:
    if d[0]>1:
      print(0)
      exit
  ans = pow(2,N//2,p)
  
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

p=10**9+7
N=int(input())
A = list(map(int,input().split()))
  
c=Counter(A)
d=dict(c)
if c.most_common()[0][1]>2:
  ans = 0
else:
  if 0 in d:
    if d[0]>1:
      print(0)
      exit
  ans = 2**(N//2)
  
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/arc066/tasks/arc066_a/

n = int(input())
nums = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
ans = 1
d = {}
if n % 2 == 1:
    for i in range(0, n, 2):
        d[i] = 0
    d[0] += 1
else:
    for i in range(1, n, 2):
        d[i] = 0
f = True
for num in nums:
    if num not in d:
        print(0, d)
        break
    d[num] += 1
else:
    for v in d.values():
        if v != 2:
            print(0)
            break
    else:
        ans = pow(2, n // 2, mod)
        print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
a=sorted(list(map(int,input().split())))
if n%2==0:
    l=[]
    for i in range(n//2):
        l.append(i*2+1)
        l.append(i*2+1)
else:
    l=[0]
    for i in range(n//2):
        l.append((i+1)*2)
        l.append((i+1)*2)

if a==l:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
a=sorted(list(map(int,input().split())))
if n%2==0:
    l=[]
    for i in range(n//2):
        l.append(i*2+1)
        l.append(i*2+1)
else:
    l=[0]
    for i in range(n//2):
        l.append((i+1)*2)
        l.append((i+1)*2)

print(l)

if a==l:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

if N % 2 == 0:
    if A == [i//2*2+1 for i in range(N)]:
        print(2**(N//2))
    else:
        print(0)
else:
    if A == [math.ceil(i/2)*2 for 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)
p = sorted(c.items())
ans = 1
if n % 2 == 0:
    for i in range(n//2):
        if p[i][0] != 2*i+1 or p[i][1] != 2:
            print(0)
            exit()
elif n % 2 == 1:
    for i in range(n//2 + 1):
        if i == 0:
            if p[i][0] != 0 or p[i][1] != 1:
                print(0)
                exit()
        elif p[i][0] != 2*i or p[i][1] != 2:
            print(0)
            exit()

print(2**(n//2))

Submission status: Wrong Answer

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

c = collections.Counter(li)
#print(c)
# Counter({'a': 4, 'c': 2, 'b': 1})
#print(c.items())
# dict_items([('a', 4), ('b', 1), ('c', 2)])
count_list = list(c.items())
count_list.sort()
keys = set(c.keys())

#print(count_list)
flag = True
if n%2 == 1:
    if keys != {i for i in range(n) if i%2 == 0}:
        print(0)
        exit()
    for i,c in enumerate(count_list):
        if c[0] == 0:
            if c[1]!=1:
                flag = False
        else:
            if c[1]!=2:
                flag = False
else:
    if keys != {i for i in range(n) if i%2 == 1}:
        print(0)
        exit()
    for i in count_list:
        if i[1] != 2:
            flag = False
if not flag:
    print(0)
    exit()

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

Submission status: Wrong Answer

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

c = collections.Counter(li)
#print(c)
# Counter({'a': 4, 'c': 2, 'b': 1})
#print(c.items())
# dict_items([('a', 4), ('b', 1), ('c', 2)])
count_list = list(c.items())
count_list.sort()


flag = True
if n%2 == 1:
    for i in count_list:
        if i[0] == 0:
            if i[1]!=1:
                flag = False
        else:
            if i[1]!=2:
                flag = False
else:
    for i in count_list:
        if i[1] != 2:
            flag = False
if not flag:
    print(0)
    exit()

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

Submission status: Wrong Answer

Solution code:
n=int(input())

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

a.sort()

ans=True
if n%2==0:
  for i in range(n//2):
    if a[i*2]!= 2*i+1 or a[i*2+1]!=2*i+1:
      ans=False
else:
  if a[0]!=0:
    ans=False
  for i in range(n//2):
    if a[i*2+1]!=i*2+2 or a[i*2+1]!=i*2+2:
      ans=False
      
      
if(ans):
  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==1:
    for i in range(n):
        if a[i]!=2*((i+1)//2):
            print(0)
            exit()
    print(2**(n//2))
else:
    for i in range(n):
        if a[i]!=(((i//2)+1)*2)-1:
            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()))
mod = 10 ** 9 + 7

cnt = Counter(a)
if n % 2 == 0:
    for i, j in cnt.items():
        if j != 2 or not(1 <= i <= n - 1) :
            print(0)
            exit()
else:
    for i, j in cnt.items():
        if i == 0:
            if j != 0:
                print(0)
                exit()
        else:
            if j != 2 or not(1 <= i <= n - 1):
                print(0)
                exit()

num = n // 2
ans = pow(2, num, mod)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a.sort()
ans = True
if n%2:
  key=0
  if a[0] != key:
    ans = False
  p = 1
else:
  key=1
  if a[0] != key or a[1] != key:
    ans = False
  p = 2

for i in range(p, n):
  if i%2 == n%2:
    key += 2
  if a[i] != key:
    ans = False
    break

if ans:
  print(pow(2, n//2))
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))

    if n % 2 != 0:
        for i in range(n - 1):
            if i == 0:
                if A[i] != 0:
                    print(0)
                    break
            else:
                if i % 2 != 0:
                    if A[i] - A[i - 1] != 2:
                        print(0)
                        break
                else:
                    if A[i] != A[i - 1]:
                        print(0)
                        break
        else:
            res = pow(2, n // 2)
            print(res)
    else:
        for i in range(n - 1):
            if i == 0:
                if A[i] != 1:
                    print(0)
                    break
            else:
                if i % 2 == 0:
                    if A[i] - A[i - 1] != 2:
                        print(0)
                        break
                else:
                    if A[i] != A[i - 1]:
                        print(0)
                        break
        else:
            res = pow(2, n // 2)
            print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    order = []
    for a in A:
        order.append(((N + 1 + a) // 2, (N + 1 - a) // 2))

    cnt = {}
    for o in order:
        if o not in cnt:
            cnt[o] = 1
        else:
            cnt[o] += 1

    ans = 1
    MOD = 1000000007
    for k, v in cnt.items():
        if k[0] == k[1] and v > 1:
            ans = 0
            break
        else:
            ans *= math.factorial(v)
            ans %= MOD
    print(ans)