Submission #1336503


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

#pragma region
LL powMod(LL num,LL n,LL mod=(LL)MOD){//(num**n)%mod
	num %= mod;//
	if( n == 0 ){
		return (LL)1;
	}
	LL mul = num;
	LL ans = (LL)1;
	while(n){
		if( n&1 ){
			ans = (ans*mul)%mod;
		}
		mul = (mul*mul)%mod;
		n >>= 1;
	}
	return ans;
}
LL mod_inverse(LL num,LL mod=MOD){
	return powMod(num,MOD-2,MOD);
}
#pragma endregion //繰り返し二乗法 powMod

void solve(){
	LL N;
	cin >> N;
	vector<LL> A(N);
	vector<int> v(N,0);//0,N-1の個数
	for(int i=0;i<N;++i){
		cin >> A[i];//[0,N-1]
		v[ A[i] ]++;
	}
	/////
	bool flag = true;
	if( N%2 == 0 ){
		for(int i=0;i<N;++i){
			if( i%2 ){
				if( v[i] != 2 ){
					flag = false;
					break;
				}
			}else{
				if( v[i] != 0 ){
					flag = false;
					break;
				}
			}
		}
	}else{//Nが奇数
		for(int i=0;i<N;++i){
			if( i%2 == 0 ){
				if( i== 0 ){
					if( v[i] != 1 ){
						flag = false;
						break;
					}
				}else{
					if( v[i] != 2 ){
						flag = false;
						break;
					}
				}
			}else{
				if( v[i] != 0 ){
					flag = false;
					break;
				}
			}
		}
	}
	if( flag ){
		cout << powMod(2,N/2) << endl;
	}else{
		cout << 0 << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()

Submission Info

Submission Time
Task C - Lining Up
User akarin55
Language C++14 (GCC 5.4.1)
Score 300
Code Size 2374 Byte
Status AC
Exec Time 10 ms
Memory 1408 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 14
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_invalid_01.txt, subtask_1_invalid_02.txt, subtask_1_max_01.txt, subtask_1_max_02.txt, subtask_1_max_valid_01.txt, subtask_1_max_valid_02.txt, subtask_1_min_valid_01.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_valid_01.txt, subtask_1_valid_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_invalid_01.txt AC 8 ms 1280 KB
subtask_1_invalid_02.txt AC 3 ms 512 KB
subtask_1_max_01.txt AC 9 ms 1408 KB
subtask_1_max_02.txt AC 9 ms 1408 KB
subtask_1_max_valid_01.txt AC 9 ms 1408 KB
subtask_1_max_valid_02.txt AC 10 ms 1408 KB
subtask_1_min_valid_01.txt AC 1 ms 256 KB
subtask_1_rand_01.txt AC 6 ms 1024 KB
subtask_1_rand_02.txt AC 9 ms 1280 KB
subtask_1_valid_01.txt AC 6 ms 896 KB
subtask_1_valid_02.txt AC 3 ms 512 KB