Submission #3888875


Source Code Expand

Copy
#include <bits/stdc++.h>

#define MOD 1000000007

template<typename T>
T power(T a, T b)
{
    T res = 1;
    while(b > 0) {
        if(b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

using namespace std;

int main()
{
    long N;
    long A[100001];
    map<long, long> count;

    cin >> N;
    for(long i = 1; i <= N; ++i) {
        cin >> A[i];
        count[A[i]]++;
    }

    if(N % 2 == 1) {
        if(count[0] != 1) goto fail;
        for(long i = 1; i < N; i++) {
            if(i % 2 == 1) {
                if(count[i] != 0) goto fail;
            }
            else {
                if(count[i] != 2) goto fail;
            }
        }
    }
    else {
        for(long i = 0; i < N; ++i) {
            if(i % 2 == 1) {
                if(count[i] != 2) goto fail;
            }
            else {
                if(count[i] != 0) goto fail;
            }
        }
    }

    cout << (N % 2 == 1 ? power(long(2), (N-1)/2) : power(long(2), (N/2))) << endl;
    return 0;

fail:
    cout << 0 << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Lining Up
User heppoko_yuki
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1137 Byte
Status
Exec Time 69 ms
Memory 7296 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 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 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_invalid_01.txt 48 ms 3584 KB
subtask_1_invalid_02.txt 9 ms 896 KB
subtask_1_max_01.txt 59 ms 4992 KB
subtask_1_max_02.txt 60 ms 4992 KB
subtask_1_max_valid_01.txt 69 ms 7296 KB
subtask_1_max_valid_02.txt 69 ms 7296 KB
subtask_1_min_valid_01.txt 1 ms 256 KB
subtask_1_rand_01.txt 34 ms 3072 KB
subtask_1_rand_02.txt 55 ms 4608 KB
subtask_1_valid_01.txt 36 ms 4096 KB
subtask_1_valid_02.txt 13 ms 1664 KB