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
N = int(input())

A = input()

if N % 2 == 0:
    for i in range(1,N,2):
        if A.count(str(i)) != 2:
            print(0)
            sys.exit()
else:
    for i in range(0,N,2):
        if i == 0:
            if A.count(str(i)) != 1:
                print(0)
                sys.exit()
        else:
            if A.count(str(i)) != 2:
                print(0)
                sys.exit()

count = (2 ** (N // 2)) % 1000000007
print(count)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

A = input()

if N % 2 == 0:
    for i in range(1,N,2):
        if A.count(str(i)) != 2:
            print(0)
            sys.exit()
else:
    for i in range(0,N,2):
        if i == 0:
            if A.count(str(i)) != 1:
                print(0)
                sys.exit()
        else:
            if A.count(str(i)) != 2:
                print(0)
                sys.exit()

count = 1
for i in range(N//2):
    count = (2 * count) % 1000000007

print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(raw_input())
ct = Counter(map(int, raw_input().split()))
correct = True
for i,j in zip(ct.keys(), ct.values()):
    if (n % 2) == (i % 2):
        correct = False
    elif i >= n-1:
        correct = False
    elif i == 0:
        if j != 1:
            correct = False
    else:
        if j != 2:
            correct = False
if correct:
    print (2**(n/2)) % (10**9+7)
else:
    print 0

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(raw_input())
ct = Counter(map(int, raw_input().split()))
correct = True
for i,j in zip(ct.keys(), ct.values()):
    if (n % 2) == (i % 2):
        correct = False
    elif i >= n:
        correct = False
    elif i == 0:
        if j != 1:
            correct = False
    else:
        if j != 2:
            correct = False
if correct:
    print 2**(n/2)
else:
    print 0

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(raw_input())
ct = Counter(map(int, raw_input().split()))
correct = True
for i,j in zip(ct.keys(), ct.values()):
    if (n % 2) == (i % 2):
        correct = False
    elif i >= n-1:
        correct = False
    elif i == 0:
        if j != 1:
            correct = False
    else:
        if j != 2:
            correct = False
if correct:
    print 2**(n/2)
else:
    print 0

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(raw_input())
ct = Counter(map(int, raw_input().split()))
correct = True
for i,j in zip(ct.keys(), ct.values()):
    if (n % 2) == (i % 2):
        correct = False
    elif i == 0:
        if j != 1:
            correct = False
    else:
        if j != 2:
            correct = False
if correct:
    print 2**(n/2)
else:
    print 0

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    i = N - 1
    while i >= 0:
        n = A.count(i)
        if (i == 0 and n != 1) or n != 2:
            print('0')
            break
        i -= 2
    else:
        comb = (2 ** (N // 2)) % 1000000007
        print(str(comb))

main()

Submission status: Wrong Answer

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

def is_satisfied(s):
    ln = len(s)
    # check = [s.count(i) == 2 for i in range(ln - 1, 1, -2)]
    for i in range(ln - 1, 1, -2):
        if not s.count(i) == 2:
            return False
    if ln % 2 == 0 and not s.count(1) == 2:
        return False
    elif not s.count(0) == 1:
        return False

    return True


ans = 2 ** (n // 2) % (10 ** 9 + 7)
print(ans if is_satisfied(a) else 0)

Submission status: Wrong Answer

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

if N % 2 == 0:
	l = list(range(1, N, 2)) * 2
else:
	l = [0] + list(range(2, N, 2)) * 2

flag = True
for i in range(N):
	if sorted(l)[i] != sorted(A):
		flag = False
		break
	
if flag == False:
	print(0)
else:
	if N % 2 == 0:
		print(int(2**(N/2)) % 1000000007)
	else:
		print(int(2**((N-1)/2)) % 1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
    Nc *= 0
else:
    for i in range(N):
        if A.count(i+1) == 2:
            Nc = Nc*2%1000000007
        elif A.count(i+1) == 0:
            Nc *= 1
        else:
            A *= 0
            break
print(Nc)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
    Nc *= 0
else:
    for i in range(N):
        if A.count(i+1) == 2:
            Nc *= 2
        elif A.count(i+1) == 0:
            Nc *= 1
        else:
            A *= 0
            break
print(Nc%1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
Nc = 1
if A.count(0) >= 2:
    Nc *= 0
else:
    for i in range(N):
        if A.count(i+1) == 2:
            Nc *= 2
        elif A.count(i+1) == 0:
            Nc *= 1
        else:
            A *= 0
            break
print(Nc)

Submission status: Wrong Answer

Solution code:
n = int(raw_input().strip())
a = map(int, raw_input().strip().split())
a.sort()


def validate(a, n):
	if n & 1 == 0:
		s = 0
		p = 1
	else:
		s = 1
		p = 2
		if a[0] != 0:
			return False
	for i in range(s, n, 2):
		if a[i] != a[i+1]:
			return False
	return True


if not validate(a, n):
	print 0
else:
	print 1 << (n >> 1)

Submission status: Wrong Answer

Solution code:

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

check = []

if N % 2 == 0:
    for i in range(1, N, 2):
        check += [i, i]
else:
    check += [0]

    for i in range(2, N, 2):
        check += [i, i]

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

Submission status: Wrong Answer

Solution code:

from collections import Counter

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

c = Counter(A)

c_v = sorted(c.values())

if N % 2 == 0:
    if c_v == [2] * (N // 2):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    if c_v == [1] + [2] * ((N - 1) // 2):
        print(2 ** ((N - 1) // 2))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:

from collections import Counter

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

c = Counter(A)

c_v = sorted(c.values())

if N % 2 == 0:
    if c_v == [2] * (N // 2):
        print(2 ** (N // 2))
    else:
        print(0)
else:
    if c_v == [1].extend([2] * ((N - 1) // 2)):
        print(2 ** ((N - 1) // 2))
    else:
        print(0)

Submission status: Wrong Answer

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

fail=False
count_list = [0]*(int((N-1)/2)+1)
for i in range(N):
	if A[i]%2==N%2:
		print(0)
		fail=True
		break
	count_list[int(A[i]/2)] = count_list[int(A[i]/2)]+1
if not fail:
	if N%2==0:
		for c in count_list:
			if c!=2:
				print(0)
				break
		else:
			result = 2
			for i in range(int(N/2)-1):
				result = result**2%(10**9+7)
			print(result)
	if N%2==1:
		if count_list[0]!=1:
			print(0)
		else:
			count_list.pop(0)
			for c in count_list:
				if c!=2:
					print(0)
					break
			else:
				if N==1:
					print(1)
				else:
					result = 2
					for i in range(int((N-1)/2-1)):
						result = result**2%(10**9+7)
					print(result)

Submission status: Wrong Answer

Solution code:
class Lining:

    def line(self, N, A):

        if N == 1:
            print 1
            return

        if N == 2:
            print 2
            return

        if N % 2:

            m = [0 for i in range((N/2)+1)]
            for a in A:
                idx = a/2
                m[idx] += 1

            if m[0] != 1:
                print 0
                return

            ans = 1
            for i in range(1, (N/2)+1):
                ans *= 2

                if m[i] != 2:
                    print 0
                    return

            print ans

        else:

            m = [0 for i in range(N/2)]
            for a in A:
                idx = a/2
                m[idx] += 1

            ans = 1
            for i in range(N/2):
                ans *= 2

                if m[i] != 2:
                    print 0
                    return

            print ans

if __name__ == "__main__":

    N = input()
    A = [int(i) for i in raw_input().split()]

    abc = Lining()
    abc.line(N, A)

Submission status: Wrong Answer

Solution code:
class Lining:

    def line(self, N, A):

        
        if N % 2:

            m = [0 for i in range((N/2)+1)]
            l = [float("inf") for i in range((N/2)+1)]
            for a in A:
                idx = a/2
                m[idx] += 1
                l[idx] = a

            if l[0] == float("inf") or m[0] != 1:
                print 0
                return

            for i in range(1, (N/2)+1):
                if m[i] != 2:
                    print 0
                    return

            print pow(2, (N/2))

        else:
            m = [0 for i in range(N/2)]
            l = [float("inf") for i in range(N/2)]
            for a in A:
                idx = a/2
                m[idx] += 1
                l[idx] = a

            for i in range(N/2):
                if m[i] != 2:
                    print 0
                    return

            print pow(2, (N/2))


if __name__ == "__main__":

    N = input()
    A = [int(i) for i in raw_input().split()]

    abc = Lining()
    abc.line(N, A)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys


def main():
    count = int(raw_input())
    li = [int(n) for n in raw_input().split()]
    if count%2 == 1: # 奇数
        if li.count(0) != 1:
            print 0
            return
        count_list = range(count)[2::2]
    else: # 偶数
        count_list = range(count)[1::2]

    for i in count_list:
        if li.count(i) != 2:
            print 0
            return
    print 2**(count/2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys


def main():
    count = int(raw_input())
    li = [int(n) for n in raw_input().split()]
    if count%2 == 1:
        if li.count(0) != 1:
            print 0
            return
        for i in range(count/2)[2::2]:
            if li.count(i) != 2:
                print 0
                return
        print 2**(count/2)
    else:
        for i in range(count/2)[1::2]:
            if li.count(i) != 2:
                print 0
                return
        print 2**(count/2)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
o, h = N%2, N//2,
arr = [0]*h
for a in map(int, input().split()):
    if a > 0:
        arr[a//2 - o] += 1
if all(c == 2 for c in arr):
    print((1 << h) // (10**9 + 7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
o, h = N%2, N//2,
arr = [0]*h
for a in map(int, input().split()):
    if a > 0:
        arr[a//2 - o] += 1
if all(c == 2 for c in arr):
    print(1 << h)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
from collections import Counter

def check(n, a):
    count = Counter(a)
    if n % 2 == 1 and (0 not in count or count[0] != 1):
        return False
    for i in range(1 + (n % 2), n+1, 2):
        if i not in count or count[i] !=2:
            return False
    return True

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

    if not check(N,A):
        print(0)
    else:
        c = 2
        for _ in range(N // 2 - 1):
            c = c * 2 % (int(1e9) + 7)
        print(c)

Submission status: Wrong Answer

Solution code:
from collections import Counter


def check(n, a):
    aa = Counter(a)
    if n & 1 and (0 not in aa or aa[0] != 1):
        return False
    for i in range(1 + (n & 1), n + 1, 2):
        if i not in aa or aa[i] != 2:
            return False
    return True


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

    if not check(n, a):
        return 0

    exp = n // 2
    if exp < 30:
        return 2 ** exp
    c = 2 ** 29
    d = 1e9 + 7
    exp -= 29
    for i in range(exp):
        c = c * 2 % d
    return c


print(solve())

Submission status: Wrong Answer

Solution code:
def mk_count_list(ls):
    length = len(ls)
    keys = list(set(ls))
    count_list = [0 for i in range(max(keys) + 1)]
    for item in keys:
        count_list[item] = ls.count(item)
    return count_list

def check_verify_pair(ls):
    length = len(ls)
    count_list = mk_count_list(ls)
    if length%2 == 0:
        for i in range(1, length + 1, 2):
            print(count_list, i)
            if count_list[i] != 2:
                return False
    if length%2 == 1:
        if count_list[0] != 1:
            return False
        for i in range(0, length + 1, 2):
            if i == 0 and count_list[i] == 1:
                continue
            if count_list[i] != 2:
                return False
    return True
if __name__ == "__main__":
    n = int(input())
    ls = list(map(int, input().split()))
    length = len(ls)
    if not check_verify_pair(ls):
        print(0)
    else:
        ans = 2**(length//2)%(10**9+7)
        print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
array=list(map(int, input().split()))

if not (0<=min(array) and max(array)<n):
    print(0)
    sys.exit()

if n%2==0:
    if (n**2)/2 != sum(array):
        print(0)
        sys.exit()
else:
    if (n**2-1)/2 != sum(array):
        print(0)
        sys.exit()

sub_list=list(set(array))

if n%2==0:
    if int(n/2)==len(sub_list):
        print(2 ** int(n / 2))
    else:
        print(0)
else:
    if int(n/2)==len(sub_list)-1:
        print(2** int(n/2))
    else:
        print(0)

Submission status: Wrong Answer

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

if not (0<=min(array) and max(array)<n):
    print(0)
    sys.exit()

if n%2==0:
    if (n**2)/2 != sum(array):
        print(0)
        sys.exit()
else:
    if (n**2-1)/2 != sum(array):
        print(0)
        sys.exit()

sub_list=list(set(array))

if n%2==0:
    if int(n/2)==len(sub_list):
        print(2 ** int(n / 2))
    else:
        print(0)
else:
    if int(n/2)==len(sub_list)-1:
        print(2** int(n/2))
    else:
        print(0)

Submission status: Wrong Answer

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

if n%2==0:
    if (n**2)/2 != sum(array):
        print(0)
        sys.exit()
else:
    if (n**2-1)/2 != sum(array):
        print(0)
        sys.exit()


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

Submission status: Wrong Answer

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

if not (0<=min(array) and max(array)<n):
    print(0)
    sys.exit()

sub_list=list(set(array))
if n%2==0:
    num=int(n/2)
    sub=1
    if 0 in array:
        print(0)
        sys.exit()
else:
    num=int(n/2)+1
    sub=0
    if array.count(0) != 1:
        print(0)
        sys.exit()

for i in sub_list:
    if i%2 != sub:
        print(0)
        sys.exit()

if len(sub_list)==num:
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

if not (0<=min(array) and max(array)<n):
    print(0)
    sys.exit()

sub_list=list(set(array))
if n%2==0:
    num=int(n/2)
    if 0 in array:
        print(0)
        sys.exit()
else:
    num=int(n/2)+1
    if array.count(0) != 1:
        print(0)
        sys.exit()
if len(sub_list)==num:
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

sub_list=list(set(array))
if n%2==0:
    num=int(n/2)
    if 0 in array:
        print(0)
        sys.exit()
else:
    num=int(n/2)+1
    if array.count(0) != 1:
        print(0)
        sys.exit()
if len(sub_list)==num:
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

sub_list=list(set(array))
if n%2==0:
    num=int(n/2)
else:
    num=int(n/2)+1
    if array.count(0) != 1:
        print(0)
        sys.exit()
if len(sub_list)==num:
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

sub_list=set(array)
if len(sub_list)==int(n/2)+1:
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

sub_list=set(array)
if len(sub_list)==int(n/2):
    print(2**int(n/2))
else: print(0)

Submission status: Wrong Answer

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

if N % 2 == 0:
    C = []
    for c in [2*i+1 for i in range(N//2)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    C = [0]
    for c in [2*i for i in range(1, N//2 + 1)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
#003
N = int(input())
list = [int(i) for i in input().split(" ")]        
list.sort()
result = 2**(len(list)//2)
if N%2==0:
    for i in range(0,N,2):
        if list[i]!=list[i+1]:
            result = 0
            
else:
    for i in range(1,N,2):
        if list[i]!=list[i+1]:
            result = 0

print(result)

Submission status: Wrong Answer

Solution code:
#003
N = int(input())
list = [int(i) for i in input().split(" ")]        
list.sort()
sample = [i for i in range(N)]
if N%2==0:
    for i in range(0,N,2):
        sample[i]=sample[i+1]
else:
    for i in range(1,N,2):
        sample[i]=sample[i+1]
if sample==list:
    print(2**(len(list)//2))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)

if n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = (2 ** m) % (1e9 + 7)
    print(ans)
elif n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = (2 ** m) % (1e9 + 7)
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
m = n//2
ca = Counter(a)
print(ca[0])

if n % 2 == 0 and all(ca[i*2 + 1] == 2 for i in range(m)):
    ans = (2 ** m) % (1e9 + 7)
    print(ans)
elif n % 2 == 1 and ca[0] == 1 and all(ca[(i+1)*2] == 2 for i in range(m)):
    ans = (2 ** m) % (1e9 + 7)
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys


def test(a):
    if len(a) % 2:
        if a[0]:
            return False

        del a[0]

    for i in range(0, len(a) - 2, 2):
        if a[i] != a[i + 1] or a[i + 2] - a[i] != 2:
            return False

    return True


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

if a[:2] == [0, 0]:
    print(0)
    sys.exit(0)

elif a == [0]:
    print(1)
    sys.exit(0)

elif a == [0, 1, 1] or a == [1, 1]:
    print(2)
    sys.exit(0)

print(2 ** round(len(a)/2) if test(a) else 0)

Submission status: Wrong Answer

Solution code:
import sys


def test(a):
    if len(a) % 2:
        if a[0]:
            return False

        del a[0]

    for i in range(0, len(a) - 2, 2):
        if a[i] != a[i + 1] or a[i + 2] - a[i] != 2:
            return False

    return True


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

if a[:2] == [0, 0]:
    print(0)
    sys.exit(0)

elif a == [0] or a == [1, 1]:
    print(1)
    sys.exit(0)

elif a == [0, 1, 1]:
    print(2)
    sys.exit(0)

print(2 ** round(len(a)/2) if test(a) else 0)

Submission status: Wrong Answer

Solution code:
import sys


def test(a):
    if len(a) % 2:
        if a[0]:
            return False

        del a[0]

    for i in range(0, len(a) - 2, 2):
        if a[i] != a[i + 1] or a[i + 2] - a[i] != 2:
            return False

    return True


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

if a[:2] == [0, 0]:
    print(0)
    sys.exit(0)

if a == [0] or a == [1, 1]:
    print(1)
    sys.exit(0)

elif a == [0, 1, 1]:
    print(2)
    sys.exit(0)

print(2 ** round(len(a)/2) if test(a) else 0)

Submission status: Wrong Answer

Solution code:

# 入力受け取り
N = int(input())
A_list = input().split()
A_list = [int(i) for i in A_list]

if N % 2 == 1:
    if A_list.count(0) > 1:
        result = 0
    else:
        i = 0
        while i < N:
            if A_list.count(A_list[i]) != 2:
                result = 0
                break
            else:
                result = ((N // 2) ** 2) % (10 ** 9 + 7)
                print("koko")
                break
            i +=1
else:
    if A_list.count(0) >= 1:
        result = 0
    else:
        i = 0
        while i < N:
            if A_list.count(A_list[i]) != 2:
                result = 0
                break
            else:
                result = ((N // 2) ** 2) % (10 ** 9 + 7)
                break
            i +=1

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
M = N//2
if N % 2 == 1 and A.count(0) == 1 and all(A.count(i*2)==2 for i in range(1,M-1)):
    print((2 ** M) % (10**9+7))
elif N % 2 == 0 and all(A.count(i*2-1)==2 for i in range(M-1)):
    print((2 ** M) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
M = N//2
if N == 1:
    if A[0] == 0:
        print(1)
    else:
        print(0)
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
    print((2 ** M) % (10**9+7))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
    print((2 ** M) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
M = N//2
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
    print((2 ** M) % (10**9+7))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
    print((2 ** M) % (10**9+7))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
a = a[0:n]
flag = 0
if(n % 2 == 1):
    if(a.count('0') != 1):
        flag = 1
    else:
        i = 2
        while i < n:
            if(a.count(str(i)) != 2):
                flag = 1
                break
            i+=2
else:
    i=1
    while i < n:
        if(a.count(str(i)) != 2):
            flag = 1
            break
        i+=2
if(flag == 0):
    print((n//2)**2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
a = a[0:n]
flag = 0
if(n % 2 == 1):
    if(a.count('0') != 1):
        flag = 1
    i = 2
    while i < n:
        if(a.count(str(i)) != 2):
            flag = 1
            break
        i+=2
else:
    i=1
    while i < n:
        if(a.count(str(i)) != 2):
            flag = 1
            break
        i+=2
if(flag == 0):
    print((n//2)**2)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def error_check(n,l):
	total = 0
	if n % 2 == 0:
		i = 1
		for k in range(n//2):
			total += (i+i)
			i += 2
		if total == sum(l):
			return True
		else:
			return False
	else:
		i = 2
		for k in range(n//2):
			total += (i+i)
			i += 2
		if total == sum(l):
			return True
		else:
			return False

n = int(input()) % (10**9 + 7)
a = list(map(int,input().split()))
m = n // 2
if error_check(n,a):
	print(2 ** m)
else:
	print(0)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())
a = [int(x) for x in input().split()]
z = Counter(a)
mul = 1
if n%2 == 1:
    if 1 in list(z.keys()):
        print(0)
        exit()
    if 0 in list(z.keys()):
        if z[0] != 1:
            print(0)
            exit()
        if z[0] == 1:
            for i in list(z.values())[1:]:
                if i == 2:
                    continue
                else:
                    print(0)
                    exit()
            print((2**(len(z.keys())-1))%(10**9+7))
    else:
        print(0)
        exit()
if n%2 == 0:
    if 0 in list(z.keys()):
        print(0)
        exit()
    if 1 in list(z.keys()):
        if z[1] != 2:
            print(0)
            exit()
        if z[1] == 2:
            for i in list(z.values()):
                if i == 2:
                    continue
                else:
                    print(0)
                    exit()
            print((2**(len(z.keys()))%(10**9+7)))
    else:
        print(0)
        exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())
A = list(map(int, input().split()))
if N % 2 == 1 and A.count(0) == 1 and np.all(A.count(i*2+2)==2 for i in range(N//2)):
    print(np.int64(np.remainder(math.pow(2, 999//2), (math.pow(10, 9) + 7))))
elif N % 2 == 0 and np.all(A.count(i*2+1)==2 for i in range(N//2)):
    print(np.int64(np.remainder(math.pow(2, 999//2), (math.pow(10, 9) + 7))))
else:
    print(0)

Submission status: Wrong Answer

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

A.sort()
if N % 2 == 1:
    if A[0] != 0:
        print(0)
    else:
        for i in range(2, N, 2):
            if A[i] != A[i - 1]:
                print(0)
                break
        else:
            print(2 ** (N // 2))
else:
    for i in range(1, N, 2):
        if A[i] != A[i - 1]:
            print(0)
            break
    else:
        print(2 ** (N // 2))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
    for i in range(N):
        if not A[i] == 2*(i/2)+1:
            flug = 1
            break

else:
    for i in range(N):
        if i % 2 == 0:
            if not A[i] == i:
                flug = 1
                break
        else:
            if not A[i] == i+1:
                flug = 1
                break
if flug == 0:
    print(pow(2, N/2))/(pow(10,9)+7)
else:
    print 0

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
    for i in range(N):
        if not A[i] == 2*(i/2)+1:
            flug = 1
            break

else:
    for i in range(N):
        if i % 2 == 0:
            if not A[i] == i:
                flug =1
                break
        else:
            if not A[i] == i+1:
                flug = 1
                break
if flug == 0:
    print(pow(2, N/2))
else:
    print 0

Submission status: Wrong Answer

Solution code:
import collections
N=int(input())
B=[]
A=[int(i) for i in input().split()]
for i in A:
 B.append(((N-1+i)/2,(N-1-i)/2))
c= collections.Counter(B)
d=1
for i,j in c.items():
 d*=j
 if j==1 and i[0]!=i[1]:
  d=0
  break
print(d)

Submission status: Wrong Answer

Solution code:
import collections
N=int(raw_input())
A=map(int, raw_input().split())
count_A=collections.Counter(A).most_common(1)
cnt = 0
if N%2 == 0:
    if A.count(0) != 0:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)
else:
    if A.count(0) != 1:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print (2**(N/2)) % (10**9+7)

Submission status: Wrong Answer

Solution code:
import collections
N=int(raw_input())
A=map(int, raw_input().split())
count_A=collections.Counter(A).most_common(1)
cnt = 0
if N%2 == 0:
    if A.count(0) != 0:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print 2**(N/2)%(10**9+7)
else:
    if A.count(0) != 1:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print 2**(N/2)%(10**9+7)

Submission status: Wrong Answer

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

dic = dict()
for a in A:
    a = int(a)
    dic[a] = dic.get(a, 0) + 1

keys = list(dic.keys())
values = list(dic.values())

if N % 2 == 0:
    if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    if keys == [2*i for i in range(N//2 + 1)] and values == [1] + [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import collections
N=int(raw_input())
A=map(int, raw_input().split())
count_A=collections.Counter(A).most_common(1)
cnt = 0
if N%2 == 0:
    if A.count(0) >= 1:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print 2**(N/2)%(10**9+7)
else:
    if A.count(0) >= 2:
        print 0
        cnt = 1
    elif count_A[0][1] != 2:
        print 0
        cnt = 1
    if cnt == 0:
        print 2**(N/2)%(10**9+7)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A=map(int, raw_input().split(' '))
A.sort()
flug = 0
if N % 2 == 0:
    for i in range(N):
        if not A[i] == 2*(i/2)+1:
            print 0
            flug = 1
            break

else:
    for i in range(N):
        if i % 2 == 0:
            if not A[i] == i:
                print 0
                flug =1
                break
        else:
            if not A[i] == i+1:
                print 0
                flug = 1
                break
if flug == 0:
    print(pow(2, N/2))

Submission status: Wrong Answer

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

if N%2 == 1:
      if A.count(0) != 1:
            error += 1
      for i in range(2, N, 2):
            if sum(A) != (N+1)/2:
                  error += 1
      if error > 0:
            print(0)
      else:
            print(int((2**((N-1)/2))%(10**9+7)))
      
else:
      if sum(A) != N/2:
            error += 1
      for i in range(1, N, 2):
            if A.count(i) != 2:
                  error += 1
      if error > 0:
            print(0)
      else:
            print(int((2**(N/2))%(10**9+7)))