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:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    tmp = N // 2
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2 and k != 0:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(2**tmp)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(2**tmp)
                        sys.exit()
                else:
                    print(2**tmp)
                    sys.exit()
        else:
            print(2**tmp)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(2**tmp)
            sys.exit()
            
    tmp = N // 2    
    print(2**tmp)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2 and k != 0:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(0)
                        sys.exit()
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = N // 2    
    print(0)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2 and k != 0:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(0)
                        sys.exit()
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = N // 2    
    print(2**tmp)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(0)
                        sys.exit()
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = N // 2    
    print(0)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2:
                ind = base.index(k)
                if base_flg[ind] == False:
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    if base_flg[ind] == False:
                        base_flg[ind] = True
                    else:
                        print(0)
                        sys.exit()
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = N // 2    
    print(2**tmp)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    base_flg = []
    
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
            base_flg.append(False)
    else:
        for i in range(1,N,2):
            base.append(i)
            base_flg.append(False)
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if k in base:
            if v == 2:
                ind = base.index(k)
                base_flg[ind] = True
            else:
                if k == 0 and v == 1:
                    ind = base.index(k)
                    base_flg[ind] = True
                else:
                    print(0)
                    sys.exit()
        else:
            print(0)
            sys.exit()
            
    for i in base_flg:
        if i == False:
            print(0)
            sys.exit()
            
    tmp = 0
    if N % 2 == 1:
        tmp = N // 2
    else:
        tmp = N // 2
        
    print(2**tmp)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    base = []
    '''
    if N % 2 == 1:
        for i in range(0,N,2):
            base.append(i)
    else:
        for i in range(1,N,2):
            base.append(i)
            '''
            
    dic = {}
    for i in A:
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1
            
    for k, v in dic.items():
        if v == 2:
            pass
        elif v == 1:
            if k == 0 and N % 2 == 1:
                pass
            else:
                print(0)
                sys.exit()
        else:
            print(0)
            sys.exit()
            
    tmp = 0
    if N % 2 == 1:
        tmp = N // 2
    else:
        tmp = N // 2
        
    print(2**tmp)
    
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())
a = list(map(int,input().split()))
MOD = 10 ** 9 + 7
ans = 1

l = collections.Counter(a)

if l[0] > 1:
    ans = 0
else:
    for vals in l.values():
        ans *= vals
    
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

C = Counter(A)

b = 1 if N % 2 == 0 else 0

for key, value in C.items():
    if b == 0 and key == b and value != 1:
        print(0)
        exit()

    if key != b and value != 2:
        print(0)
        exit()
    b += 2

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

Submission status: Wrong Answer

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

if n%2==0:
  for i in range(0,n//2+1,2):
    if not a[i]==a[i+1]==i+1:
      print("0")
      exit(0)
  print(2**(n//2))

else:
  b=[0]+a
  for i in range(0,(n+1)//2+1,2):
    if not b[i]==b[i+1]==i:
      print("0")
      exit(0)
  print(2**((n-1)//2))

Submission status: Wrong Answer

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

n = N // 2
c = N - 1
for _ in range(n):
  a, b = A.pop(), A.pop()
  if (a != c) or (b != c):
    print(0)
    exit()
  c -= 2
      
if N % 2 == 1 and A[0] != 0:
    print(0)
    exit()
  
print(2 ** (N // 2))

Submission status: Wrong Answer

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

n = N // 2
c = N - 1
for _ in range(n):
  a, b = A.pop(), A.pop()
  if (a != c) or (b != c):
    print(0)
    exit()
  c -= 2
      
if N % 2 == 1 and A[0] != 0:
    print(0)
    exit()
  
print((N // 2) ** 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
cr_A = []
flag = 1
if N%2:
	cr_A.append(0)
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i]*2)
else:
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i - 1]*2)

if A == cr_A:
	if N > 1:
		print(((N//2)**2)%(10**9 + 7))
	else:
		print(1)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
cr_A = []
flag = 1
if N%2:
	cr_A.append(0)
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i]*2)
else:
	for i in range(1, N//2 + 1):
		cr_A.extend([2*i - 1]*2)

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

Submission status: Wrong Answer

Solution code:
import itertools

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

if N%2==0:
    n=N//2
    plist=[]
    for i in range(n):
        plist=plist+[2*i+1]*2
    
    count=0    
    for v in itertools.permutations(plist, N):
        v=list(v)
    
        if A == v:
            count=count+1
        else: 
            count=count
            
    if count>1:
        print(2**n%(10**9+7))
    else: 
        print(0)
    
if N%2==1:
    n=N//2
    plist=[0]
    for i in range(1, n+1):
        plist=plist+[2*i]*2
    
    count=0
    for v in itertools.permutations(plist, N):
        ｖ=list(v)
        
        if A == v:
            count=count+1
        else: 
            count=count
            
    if count>1:
        print(2**n%(10**9+7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

flg = False
if N % 2 ==0:
  cnt = 0
  for i in range(N // 2):
    if A[2*i+1] != 2 or A[2*i] != 0:
      flg = True
      break
  else:
    cnt += 2
  if cnt != N:
    flg = True
  else:
    print ((2 ** (N//2)) % (10 ** 9 + 7))
else:
  if A[0] != 1:
    flg = True
  else:
    cnt = 1
    for i in range(N // 2):
      if A[2*(i+1)] != 2 or A[2*i+1] != 0:
        flg =True
        break
      else:
        cnt += 2
    if cnt != N:
      flg = True
    else:
      print ((2 ** (N //2)) % (10 ** 9 + 7))
if flg: print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

flg = False
if N % 2 ==0:
  for i in range(N // 2):
    if A[2*i+1] != 2 or A[2*i] != 0:
      flg = True
      break
  print ((2 ** (N//2)) % (10 ** 9 + 7))
else:
  if A[0] != 1:
    flg = True
  else:
    for i in range(N // 2):
      if A[2*(i+1)] != 2 or A[2*i+1] != 0:
        flg =True
        break
    print ((2 ** (N //2)) % (10 ** 9 + 7))
if flg: print(0)

Submission status: Wrong Answer

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

flg = False
if N % 2 ==0:
  for i in range(N // 2):
    if A.count(2*i+1) != 2:
      flg = True
      break
  print ((2 ** (N//2)) % (10 ** 9 + 7))
else:
  if A.count(0) != 1:
    flg = True
  else:
    for i in range(N // 2):
      if A.count(2*(i+1)) != 2:
        flg =True
        break
    print ((2 ** (N //2)) % (10 ** 9 + 7))
if flg: print(0)

Submission status: Wrong Answer

Solution code:
import collections

N = int(input())
lst = list(map(int, input().split()))
c = dict(collections.Counter(lst))
ans = 2 ** (N // 2)
if (N % 2 != 0):
  for i in range(0, N, 2):
    if (i not in c.keys()):
      ans = 0
      break
    else:
      if (i == 0):
        if (c[i] != 1):
          ans = 0
          break
      else:
        if (c[i] != 2):
          ans = 0
          break
else:
  for i in range(1, N, 2):
    if (i not in c.keys()):
      ans = 0
      break
    else:
      if (c[i] != 2):
        ans = 0
        break
      
print(ans)

Submission status: Wrong Answer

Solution code:
import collections


n = int(input())
A = input().split()
d = collections.defaultdict(int)
for a in A:
    d[a] += 1
if n == 1:
    print(1)
    exit()
if n % 2 != 0:
    if '0' not in d or d['0'] != 1:
        print(0)
        exit()
    for i in range(2, n, 2):
        if str(i) not in d or d[str(i)] != 2:
            print(0)
            exit()
else:
    if '0' in d:
        print(0)
        exit()
    for i in range(1, n, 2):
        if str(i) not in d or d[str(i)] != 2:
            print(0)
            exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
import collections


n = int(input())
A = input().split()
d = collections.defaultdict(int)
for a in A:
    d[a] += 1
if n == 1:
    print(1)
    exit()
if n % 2 != 0:
    if '0' not in d or d['0'] != 1:
        print(0)
        exit()
    del d['0']
else:
    if '0' in d:
        print(0)
        exit()
if any([v != 2 for v in d.values()]):
    print(0)
    exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
import collections


n = int(input())
A = input().split()
d = collections.defaultdict(int)
for a in A:
    d[a] += 1
if n % 2 != 0:
    if '0' not in d or d['0'] != 1:
        print(0)
        exit()
    del d['0']
else:
    if '0' in d:
        print(0)
        exit()
if any([v != 2 for v in d.values()]):
    print(0)
    exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
from  collections import Counter

n =int(input())

a = list(input().rstrip().split())

count_num = Counter(a)

result = True

if len(a) == n:
    if n % 2 == 0:
        for i in range(n-1, -1, -2):
            if count_num[str(i)] ==2:
                continue
            else:
                result = False
                break

    else:
        if count_num['0'] == 1:
            for i in range(n-1, 1, -2):                
                if count_num[str(i)] ==2:continue
                else:
                    result = False
                    break

if result: print(2**int(n/2) % (10**9+7))
else:print(0)

Submission status: Wrong Answer

Solution code:
n =int(input())

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

result = False

if len(a) == n:
    if n % 2 == 0:
        for i in range(n-1, -1, -2):
            if a.count(i) !=2:break
            result = True

    else:
        if a.count(0) == 1:
            for i in range(n-1, 1, -2):
                if i != 0 and a.count(i) !=2:break
                result = True  
if result: print(2**int(n/2) % (10**9+7))
else:print(0)

Submission status: Wrong Answer

Solution code:
n =int(input())

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

result = False

if len(a) == n:
    for i in range(n-1, -1, -2):
        if i not in set(a):
            result = False
            break
    result = True

if result:print(2**int(n/2) % (10**9 + 7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list(map(int, input().split()))
a = collections.Counter(a)
cnt = 1
for k, v in a.items():
    if k == 0 and v == 1 and n % 2 != 0:
        cnt *= 1
    elif k == 0 and v == 2 and n % 2 == 0:
        cnt *= 1
    elif k != 0 and v == 2:
        cnt *= 2
    else:
        print(0)
        exit()
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    if n > ((i+1)*2-1):
        b.append(n-((i+1)*2-1))
    else:
        b.append(((i+1)*2-1)-n)

a.sort()
b.sort()
if a==b:
    print(2**(n//2))
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag=True

if n%2==0:
    if 0 in A or len(set(A))!=n//2+1:
        flag=False
else:
    if len([0 for a in A if a==0])!=1 or len(set(A))!=n//2+1:
        flag=False
    
print(2**(n//2)%(10**9+7) if flag else 0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

bucket = [0 for _ in range(N)]

if N % 2 == 0:
	even = True
else:
	even = False

Not0 = True

for i in range(N):
	if even:
		if A[i] % 2 == 0:
			print(0)
			Not0 = False
			break
		else:
			if bucket[A[i]] == 2:
				print(0)
				Not0 = False
				break
			else:
				bucket[A[i]] += 1
	else:
		if A[i] % 2 == 1:
			print(0)
			Not0 = False
			break
		else:
			if bucket[A[i]] == 2:
				print(0)
				Not0 = False
				break
			else:
				bucket[A[i]] += 1

if Not0:
	if not even:
		if bucket[0] != 1:
			print(0)
			Not0 = False

if Not0:
	print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l)

Submission status: Wrong Answer

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

A.sort()


T=[]
if n%2==0:
    for i in range(n//2):
        T.append(2*i+1)
        T.append(2*i+1)
else:
    T.append(0)
    for i in range(n//2):
        T.append(2*i+2)
        T.append(2*i+2)
        
for i in range(n):
    if A[i] != T[i]:
        print(0)
        break
else:
    print(2**(n//2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 2 ** (n // 2)
print(ans % mod)

Submission status: Wrong Answer

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


def solve(N, A):
    counter = Counter(A)
    if N % 2 == 1:
        for a, n in counter.items():
            print(a, n)
            if a == 0 and n == 1:
                continue
            if a % 2 != 0 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007
    else:
        for a, n in counter.items():
            if a % 2 != 1 or n != 2:
                return 0
        return (2**(N//2)) % 1000000007

print(solve(N, A))

Submission status: Wrong Answer

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


def solve(N, A):
    counter = Counter(A)
    if N % 2 == 1:
        for a, n in counter.items():
            if a % 2 != 0 or n != 2:
                return 0
        return 2**(N//2) % 1000000007
    else:
        for a, n in counter.items():
            if a % 2 != 1 or n != 2:
                return 0
        return 2**(N//2) % 1000000007

print(solve(N, A))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections

MOD = 1000000007  # type: int

def mpow(n, base):
    res = 1
    for i in range(n):
        res = res * base % MOD
    return res

def solve(N: int, A: "List[int]"):
    A.sort()
    if N % 2 == 0:
        for i in range(0, N//2):
            if A[2*i] != 2*i+1 or A[2*i+1] != 2*i+1:
                print(0)
                return
        print(mpow(N//2, 2))
    else:
        for i in range(0, N//2):
            if i == 0:
                if A[0] != 0:
                    print(0)
                    return
                else:
                    continue
            if A[i] != 2*i or A[i+1] != 2*i:
                print(0)
                return
        print(mpow(N//2, 2))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
half = math.floor(N/2)
ans = 2**(half)
if N%2 == 1 and A[-1] !=0:
  ans = 0
for i in range(half):
  if A[2*i] == N-2*i-1 and A[2*i+1] == N-2*i-1:
    continue
  else:
    ans = 0
    break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if n%2 == 1:
  if a[0]!=0:
    print(0)
    exit()
  for i,j,k in zip(a[1::2],a[2::2],range(2,n,2)):
    if not i==j==k:
      print(0)
      exit()
  print(2**(n//2))
  exit()
for i,j,k in zip(a[::2],a[1::2],range(1,n,2)):
  if not i==j==k:
    print(0)
    exit()
print(pow(2,n//2,10**9+7))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if n%2 == 1:
  if a[0]!=0:
    print(0)
    exit()
  for i,j,k in zip(a[1::2],a[2::2],range(2,n,2)):
    if not i==j==k:
      print(0)
      exit()
  print(2**(n//2))
  exit()
for i,j,k in zip(a[::2],a[1::2],range(1,n,2)):
  print(i,j,k)
  if not i==j==k:
    print(0)
    exit()
print(pow(2,n//2,10**9+7))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if n%2 == 1:
  if a[0]!=0:
    print(0)
    exit()
  for i,j,k in zip(a[1::2],a[2::2],range(2,n,2)):
    if not i==j==k:
      print(0)
      exit()
  print(2**(n//2))
  exit()
for i,j,k in zip(a[::2],a[1::2],range(1,n,2)):
  if not i==j==k:
    print(0)
    exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
if n%2 == 1:
  if a[0]!=0:
    print(0)
    exit()
  for i,j,k in zip(a[1::2],a[2::2],range(0,n,2)):
    if not i==j==k:
      print(0)
      exit()
  print(2**(n//2))
  exit()
for i,j,k in zip(a[::2],a[1::2],range(0,n,2)):
  if not i==j==k:
    print(0)
    exit()
print(2**(n//2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().rstrip().split()))
A.sort()
ANS = 2**(N//2)

if N%2 == 0:
    if A[0] and A[1] != 1:
        print(0)
        exit()
    for i in range(N,2):
        if A[i] != A[i+1]:
            print(0)
            exit()
else:
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, N, 2):
        if A[i] != A[i+1]:
            print(0)
            exit()

print(ANS%(10**9+7))

Submission status: Wrong Answer

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

#nが偶数の時
if n%2==0:
    check=[]
    for i in range(1,n,2):
        check.append(i)
        check.append(i)
    if check==rowdata:
        print(int(2**(int(n/2))))
    else:
        print(0)
else:
    check=[]
    for i in range(0,n,2):
        if i==0:
            check.append(i)
        else:
            check.append(i)
            check.append(i)
    if check==rowdata:
        print(int(2**(int((n-1)/2))))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
rowdata=input()

#nが偶数の時
if n%2==0:
    check=0
    for i in range(1,n,2):
        if rowdata.count(str(i))!=2:
            check+=1
    if check==0:
        print(int(2**(n/2)))
    else:
        print(0)
else:
    check=0
    for i in range(0,n,2):
    
        if i==0:
            if rowdata.count(str(i))!=1:
                check+=1
        else:
            if rowdata.count(str(i))!=2:
                check+=1
    if check==0:
        print(int(2**((n-1)/2)))
    else:
        print(0)