AtCoder Regular Contest 066

Submission #1031642

Source codeソースコード

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int mod = 1e9 + 7;

ll pow_mod(int x) {
  if (x == 0) {
    return 1;
  }
  ll y = pow_mod(x / 2);
  y = (y * y) % mod;
  if (x % 2 == 1) {
    y  = y * 2 % mod;
  }
  return y;
}

int main() {
  int n;
  scanf("%d", &n);
  vll a(n);
  rep (i, n) {
    scanf("%lld", &a[i]);
  }
  sort(all(a));
  if (n % 2 == 0) {
    rep (i, n) {
      int expect = i / 2 * 2 + 1;
      if (a[i] != expect) {
        printf("0\n");
        return 0;
      }
    }
    ll ans = pow_mod(n / 2);
    printf("%lld\n", ans);
    return 0;
  } else {
    if (a[0] != 0) {
      printf("0\n");
      return 0;
    }
    FOR (i, 1, n) {
      int expect = (i+1) / 2 * 2;
      if (a[i] != expect) {
        printf("0\n");
        return 0;
      }
    }
    ll ans = pow_mod(n / 2);
    printf("%lld\n", ans);
  }

  return 0;
}

Submission

Task問題 C - Lining Up
User nameユーザ名 056 tspcx
Created time投稿日時
Language言語 C++14 (Clang 3.8.0)
Status状態 AC
Score得点 300
Source lengthソースコード長 1822 Byte
File nameファイル名
Exec time実行時間 20 ms
Memory usageメモリ使用量 1024 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt
All 300 / 300 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 9 ms 888 KB
sample_02.txt AC 3 ms 256 KB
sample_03.txt AC 3 ms 256 KB
subtask_1_invalid_01.txt AC 17 ms 896 KB
subtask_1_invalid_02.txt AC 5 ms 384 KB
subtask_1_max_01.txt AC 19 ms 1024 KB
subtask_1_max_02.txt AC 19 ms 1024 KB
subtask_1_max_valid_01.txt AC 19 ms 1024 KB
subtask_1_max_valid_02.txt AC 20 ms 1024 KB
subtask_1_min_valid_01.txt AC 3 ms 256 KB
subtask_1_rand_01.txt AC 13 ms 768 KB
subtask_1_rand_02.txt AC 18 ms 1024 KB
subtask_1_valid_01.txt AC 12 ms 640 KB
subtask_1_valid_02.txt AC 6 ms 384 KB