Submission #19612816


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll N; cin >> N;
  vector<ll> A(N, 0);
  for (ll i = 0; i < N; i++) {
    string S; cin >> S;
    if (S[0] == 'A') A[i] = 1;
  }

  vector<ll> pow2(62, 0);
  pow2[0] = 1;
  for (ll i = 0; i < 61; i++) {
    pow2[i + 1] = pow2[i] * 2;
  }

  vector<ll> dp(N + 5, 0);
  dp[0] = 1;
  for (ll i = 0; i < N; i++) {
    if (A[i] == 1) {
      dp[i + 1] = dp[i];
    } else {
      dp[i + 1] = dp[i] + pow2[i + 1];
    }
  }
  ll ans = dp[N];
  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task D - Logical Expression
User nakaken88
Language C++ (GCC 9.2.1)
Score 400
Code Size 634 Byte
Status AC
Exec Time 7 ms
Memory 3648 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 21
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All max_01.txt, max_02.txt, min_01.txt, min_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
max_01.txt AC 7 ms 3576 KiB
max_02.txt AC 4 ms 3508 KiB
min_01.txt AC 2 ms 3588 KiB
min_02.txt AC 2 ms 3500 KiB
random_01.txt AC 2 ms 3616 KiB
random_02.txt AC 3 ms 3648 KiB
random_03.txt AC 2 ms 3620 KiB
random_04.txt AC 2 ms 3620 KiB
random_05.txt AC 2 ms 3456 KiB
random_06.txt AC 2 ms 3648 KiB
random_07.txt AC 2 ms 3456 KiB
random_08.txt AC 2 ms 3588 KiB
random_09.txt AC 2 ms 3576 KiB
random_10.txt AC 3 ms 3520 KiB
random_11.txt AC 2 ms 3464 KiB
random_12.txt AC 5 ms 3504 KiB
random_13.txt AC 2 ms 3616 KiB
random_14.txt AC 3 ms 3508 KiB
random_15.txt AC 2 ms 3524 KiB
sample_01.txt AC 2 ms 3616 KiB
sample_02.txt AC 2 ms 3516 KiB