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, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = collections.Counter(A)

    start = 1 if N % 2 == 0 else 0
    m = 0
    for n in range(start, N, 2):
        if n == 0 and cnt[n] == 1:
            continue
        elif cnt[n] == 2:
            m += 1
            continue
        else:
            print(0)
            exit()
    print((m**2)%MOD)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = collections.Counter(A)

    start = 1 if N % 2 == 0 else 0
    m = 0
    for n in range(start, N, 2):
        if n == 0 and cnt[n] == 1:
            continue
        elif cnt[n] == 2:
            m += 1
            continue
        else:
            print(0)
            exit()
    print(m**2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if A_test == judge:
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)

ans = ans % (10**9 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
lenS=len(S)
T=[]
for i in range(1,N+1):
    T.append(abs(i-(N+1-i)))

T.sort()
S.sort()



for i in range(N):
    if T!=S:
        print(0)
        exit()

'''
ans=1
nagasa=lenS//2
for i in range(nagasa):
    
    ans=(ans*2)%(10**9+7)

print(ans)


'''

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(map(int,input().split()))
lenS=len(S)
T=[]
for i in range(1,N+1):
    T.append(abs(i-(N+1-i)))

T.sort()
S.sort()


'''
for i in range(N):
    if T!=S:
        print(0)
        exit()


ans=1
nagasa=lenS//2
for i in range(nagasa):
    
    ans=(ans*2)%(10**9+7)

print(ans)


'''

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = collections.Counter(A)

    for k, v in cnt.items():
        if k == 0 and v != 1:
            print(0)
            exit()
        elif k != 0 and v != 2:
            print(0)
            exit()
    print(2 ** (N // 2))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
K = [0 for i in range(N+1)]
A = list(map(int,input().rstrip().split(" ")))
ans = 1
for i in A:
    K[i] += 1
for i in range(N):
    if i != 0 and K[i] != 0 and K[i] != 2:
        ans = -1
        break
    if K[i] == 2:
        ans *= 2
        ans %= 10 ** 9 + 7
print(ans)

Submission status: Wrong Answer

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

if len(a)%2==1:
    tmp = [0]
    for i in range((len(a)-1)//2):
        tmp.append((i+1)*2)
        tmp.append((i+1)*2)
    if a == tmp:
        ans = 2**((len(a)-1)//2)
    else:
        ans = 0
else:
    tmp = []
    for i in range(len(a)//2):
        tmp.append(2*i+1)
        tmp.append(2*i+1)
    if a == tmp:
        ans = 2**(len(a)//2)
    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    counter = collections.Counter(A)
    keys = [False]*N
    keys[(N - 1) % 2] = True
    for n in range(1, N//2):
        keys[((N - 1) % 2)+2*n] = True

    if N % 2 != 0 and counter[0] != 1:
        print(0)
        exit()

    cnt = 0
    for k, v in counter.items():
        if k == 0: continue
        if not keys[k] or v != 2:
            print(0)
            exit()
        cnt += 1

    print((N // 2) * cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    counter = collections.Counter(A)
    keys = [0]*(N//2 + 1)
    keys[0] = (N - 1) % 2
    for n in range(1, N//2+1):
        keys[n] = keys[n-1] + 2

    if N % 2 != 0 and counter[0] != 1:
        print(0)
        exit()

    cnt = 0
    for k, v in counter.items():
        if k == 0: continue
        if k not in keys or v != 2:
            print(0)
            exit()
        cnt += 1

    print((N // 2) * cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    counter = collections.Counter(A)
    if N % 2 != 0 and counter[0] != 1:
        print(0)
        exit()

    cnt = 0
    for k, v in counter.items():
        if k == 0: continue
        if v != 2:
            print(0)
            exit()
        cnt += 1

    print((N//2)*cnt)





if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    cnt = collections.Counter(A)

    if N % 2 == 0:
        i = 1
        while i < N:
            if cnt[i] == 2:
                i += 2
            else:
                print(0)
                exit()
        print(N*2)
    else:
        if cnt[0] != 1:
            print(0)
            exit()
        i = 2
        while i < N:
            if cnt[i] == 2:
                i += 2
            else:
                print(0)
                exit()
        print(N-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

# 偶数の場合
if N % 2 == 0:
    c = Counter(A)
    if all(i == 2 for i in c.values()):
        print(2 ** (N//2))
    else:
        print(0)
# 奇数の場合
else:
    A.sort()
    A = A[1:]
    c = Counter(A)
    if all(i == 2 for i in c.values()):
        print(2 ** (N//2))
    else:
        print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    if N is odd, 
    N-1 : 2
    N-3 : 2
    0   : 1
    if N is even,
    N-1 : 2
    N-3 : 2
    1   : 1


    1 2 3 4 5 6
    1 2 3 4 5
    """
    N = read_int()
    A = read_ints()
    D = [0]*((N+1)//2)
    if N%2 == 0:
        for a in A:
            if a%2 == 0:
                return 0
            if a >= N:
                return 0
            if D[a//2] == 2:
                return 0
            D[a//2] += 1
    else:
        for a in A:
            if a%2 == 1:
                return 0
            if a >= N:
                return 0
            if D[a//2] == 2:
                return 0
            if D[0] == 2:
                return 0
            D[a//2] += 1
    return 2**(N//2)


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
if max(a.keys())>n:
  print(0)
  exit()
if n%2:
  for i in a.keys():
    if i%2:
      print(0)
      exit()
  if a[0]!=1:
    print(0)
    exit()
  a[0]=2
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2))
else:
  for i in a.keys():
    if i%2==0:
      print(0)
      exit()
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
if max(a.keys())>n:
  print(0)
  exit()
if n%2:
  for i in a.keys():
    if i%2:
      print(0)
      exit()
  if a[0]!=1:
    print(0)
    exit()
  a[0]=2
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2))
else:
  for i in a.keys():
    if i%2==0:
      print(0)
      exit()
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2)//(10**9+7))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
if max(a.keys())>n:
  print(0)
  exit()
if n%2:
  for i in a.keys():
    if i%2:
      print(0)
      exit()
  if a[0]!=1:
    print(0)
    exit()
  a[0]=2
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2))
else:
  for i in a.keys():
    if i%2==0:
      print(0)
      exit()
  for i in a.values():
    if i!=2:
      print(0)
      exit()
  print(2**(n//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
if n % 2 == 0:
    if ls[::2] == ls[1::2] and ls[::2] == [e for e in range(n) if e % 2 != 0]:
        print(2**(int(n/2)))
    else:
        print(0)
else:
    if ls[1::2] == ls[2::2] and ls[::2] ==  [e for e in range(n) if e % 2 == 0]:
        print(2**(int(n/2)))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n = int(input())
A = iarr()
s = set(A)
if len(A)==2*len(s) or len(A)==2*(len(s)-1):
    print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n = int(input())
A = iarr()
s = set(A)
if len(A)==2*len(s) or len(A)==2*len(s)-1:
    print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n = int(input())
A = iarr()
s = set(A)
if len(A)//2==len(s): print(pow(2, len(A)//2, int(1e9+7)))
else: print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import ceil

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

# a position where a person could be located.
possibility = ([0 for i in range(N)])

THE_NUM = 10**9 + 7

is_exist_liar = False
# testimony
for a in A:
  # to find the number of reordering, you can only count one side.
  place_left = (N - 1 - a) // 2
  if (N - 1 - a) % 2 == 0 and place_left >= 0:
    possibility[place_left] += 1
  else:
    is_exist_liar = True
    break

answer = 1
# there is no need to count the center.
for i in range(N // 2):
  if possibility[i] <= 2:
    answer *= possibility[i]
  else:
    is_exist_liar = True
    break

# it is consistent to have more than two numbers in the middle.
if is_exist_liar or N % 2 == 1 and possibility[N//2] >= 2:
  print(0)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import ceil

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

# a position where a person could be located.
possibility = ([0 for i in range(N)])

THE_NUM = 10**9 + 7

is_exist_liar = False
# testimony
for a in A:
  # to find the number of reordering, you can only count one side.
  place_left = (N - 1 - a) // 2
  if (N - 1 - a) % 2 == 0 and place_left >= 0:
    possibility[place_left] += 1
  else:
    is_exist_liar = True
    break

answer = 1
# there is no need to count the center.
for i in range(N // 2):
  if possibility[i] <= 2:
    answer *= possibility[i]
  else:
    is_exist_liar = True
    break

print(possibility)

# it is consistent to have more than two numbers in the middle.
if is_exist_liar or N % 2 == 1 and possibility[N//2] >= 2:
  print(0)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import ceil

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

# a position where a person could be located.
possibility = ([0 for i in range(N)])

THE_NUM = 10**9 + 7

is_exist_liar = False
# testimony
for a in A:
  # to find the number of reordering, you can only count one side.
  place_left = (N - 1 - a) // 2
  if (N - 1 - a) % 2 == 0 and place_left >= 0:
    possibility[place_left] += 1
  else:
    is_exist_liar = True
    break

answer = 1
# there is no need to count the center.
for i in range(N // 2):
  answer *= possibility[i]

# it is consistent to have more than two numbers in the middle.
if is_exist_liar or N % 2 == 1 and possibility[N//2] >= 2:
  print(0)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from math import ceil

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

# a position where a person could be located.
possibility = ([0 for i in range(N)])

THE_NUM = 10**9 + 7

# testimony
for a in A:
  # to find the number of reordering, you can only count one side.
  place_left = (N - 1 - a) // 2
  possibility[place_left] += 1

answer = 1
# there is no need to count the center.
for i in range(N // 2):
  answer *= possibility[i]

# it is consistent to have more than two numbers in the middle.
if N % 2 == 1 and possibility[N//2] >= 2:
  print(0)
else:
  print(answer)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
freq = Counter(a)
ordering = []
for i in range(n):
    right = n - i - 1
    left = i
    ordering.append(abs(right - left))
freq2 = Counter(ordering)
if freq != freq2:
    print(0)
else:
    result = 1
    for x in freq.values():
        result *= x
    print(result)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
flag = True
c = Counter(a)
print(c)
if n % 2 == 1:
    if c[0] != 1:
        flag = False
    for i in range(1, n//2+1):
        if c[i*2] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)
elif n % 2 == 0:
    for i in range(n//2):
        if c[i*2+1] != 2:
            flag = False
            break
    if flag:
        print(2**(n//2) % mod)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = sorted(map(int, input().split()))
if n % 2 == 0:
    if nums[::2] != nums[1::2]:
        print(0)
    else:
        print(2 ** (n // 2))
else:
    if nums[0] == 0 and nums[1::2] == nums[2::2]:
        print(2 ** (n // 2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import numpy as np

n = int(input())
a = list(map(int, input().split()))
count = Counter(a)
# 0の個数は、count[0]
num = len(a)
ans = 1


if (num % 2 == 0):
    # 偶数パターン
    temp = 1
    loop = int(num / 2)
    for i in range(loop):
        tar = count[temp]
        if (tar == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

else:

    tar0 = count[0]
    if (tar0 == 1):
        pass
    else:
        print(0)
        exit()

    temp = 2

    for i in range(num // 2):
        if (count[temp] == 2):
            ans *= 2
            temp += 2
        else:
            print(0)
            exit()

print(ans)

Submission status: Wrong Answer

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

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

flag=True
if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
    else:
        flag=False
    for i in range(n-1):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False
else:
    for i in range(n):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            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()))

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

flag=True
if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
    for i in range(n-1):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            flag=False
else:
    for i in range(n):
        if (i%2==1 and cnt_lst[i]!=2) or (i%2==0 and cnt_lst[i]!=0):
            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()))

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]
flag=False

if n%2==1 and cnt_lst[0]==1:
    cnt_lst.pop(0)
if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
    flag=True
print(2**(n//2) if flag else 0)

Submission status: Wrong Answer

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

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]

if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
        if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
            print(2**(n//2))
        else:
            print(0)
    else:
        print(0)
else:
    if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

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

from collections import Counter
c=Counter(a)

cnt_lst=[0]*n
for key in c:
    cnt_lst[key]+=c[key]


if n%2==1:
    if cnt_lst[0]==1:
        cnt_lst.pop(0)
        print(cnt_lst)
        if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
            print(2**(n//2))
        else:
            print(0)
    else:
        print(0)
else:
    if all([cnt_lst[i]==2 for i in range(n-1) if i%2==1]):
        print(2**(n//2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter
import math

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

combi = []
for i in range(n):
    l = i
    r = n - i - 1
    combi.append(abs(l - r))

if sorted(combi) == sorted(a):
    c = Counter(combi)
    ans = 1
    for i in c.values():
        ans *= math.factorial(i)
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

combi = []
for i in range(n):
    l = i
    r = n - i - 1
    combi.append(abs(l - r))

if sorted(combi) == sorted(a):
    c = Counter(combi)
    ans = 1
    for i in c.values():
        ans *= i
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

if N % 2 == 1:

    memo = {key:0 for key in [i for i in range(2, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(2, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if check_num == 0:
            if memo[check_num] != 1:
                print(0)
                quit()
        if memo[check_num] != 2:
            print(0)
            quit()

else:
    memo = {key:0 for key in [i for i in range(1, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(1, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if memo[check_num] != 2:
            print(0)
            quit()

ans = 2 ** len(check_list)
if N == 1:
    if A[0] == 0:
        print(1)
    else:
        print(0)
print(ans)

Submission status: Wrong Answer

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

if N % 2 == 1:

    memo = {key:0 for key in [i for i in range(2, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(2, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if check_num == 0:
            if memo[check_num] != 1:
                print(0)
                quit()
        if memo[check_num] != 2:
            print(0)
            quit()

else:
    memo = {key:0 for key in [i for i in range(1, N, 2)]}

    for a in A:
        try:
            memo[a] += 1
        except:
            memo[a] = 1

# print(memo)

    check_list = {}
    for i in range(1, N, 2):
        check_list[i] = False

    for check_num in check_list.keys():
        if memo[check_num] != 2:
            print(0)
            quit()

ans = 2 ** len(check_list)
print(ans)

Submission status: Wrong Answer

Solution code:
t = int(input())
m = list(map(int,input().split()))
q={}
z=False
cnt0=0
for i in range(t):
    d=m[i]
    a=(t-1-d)//2
    if d==0:
        cnt0+=1
    if (a,a+d) not in q:
        q[(a,a+d)]=0
    q[(a,a+d)]+=1
    if q[(a,a+d)]>2:
        z=True
        break
if z or cnt0>1:
    print(0)
elif cnt0==1 and t%2==0:
    print(0)

   
else:
    res=1
    for i in q:
        if i[0]==i[1]:
            res=res*1
        else:
            res=res*2
    print(res)

Submission status: Wrong Answer

Solution code:
t = int(input())
m = list(map(int,input().split()))
q={}
z=False
cnt0=0
for i in range(t):
    d=m[i]
    a=(t-1-d)//2
    if d==0:
        cnt0+=1
    if (a,a+d) not in q:
        q[(a,a+d)]=0
    q[(a,a+d)]+=1
    if q[(a,a+d)]>2:
        z=True
        break
if z or cnt0>1:
    print(0)
 
   
else:
    res=1
    for i in q:
        if i[0]==i[1]:
            res=res*1
        else:
            res=res*2
    print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ok = True
if n%2==1:
    a=sorted(A)
    for i in range(len(a)):
        if i%2==0:
            if a[i]!=i:
                ok = False
        else:
            if a[i]!=i+1:
                ok = False
else:
    a=sorted(A)
    for i in range(len(a)):
        if i%2==1:
            if a[i]!=i:
                ok = False
        else:
            if a[i]!=i+1:
                ok = False
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()

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