Submission #19559795


Source Code Expand

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

ll solve(int N, string T,  ll cnt) {
  if (T == "1") return 2*cnt;
  else if (T == "0" || T == "11") return cnt;
  else {
    if (1 <= N && T.substr(0, 1) == "0") {
      T = T.substr(1);
      N--, cnt--;
    }
    else if (2 <= N && T.substr(0, 2) == "10") {
      T = T.substr(2);
      N -= 2, cnt--;
    }
    if (N % 3 == 1) {
      if (T.substr(N-1) == "1") {
        T = T.substr(0, N-1);
        N--, cnt--;
      }
      else return 0;
    }
    else if (N % 3 == 2) {
      if (T.substr(N-2) == "11") {
        T = T.substr(0, N-2);
        N -= 2, cnt--;
      }
      else return 0;
    }
    for (int i = 0; i < N; i += 3) {
      if (T.substr(i, 3) != "110") return 0;
      cnt--;
    }
    return cnt+1;
  }
}
int main() {
  int N;
  string T;
  cin >> N >> T;
  ll cnt = 10000000000;
  ll ans = solve(N, T, cnt);
  cout << ans << endl;
}

Submission Info

Submission Time
Task B - Many 110
User yakisaba
Language C++ (GCC 9.2.1)
Score 400
Code Size 970 Byte
Status AC
Exec Time 16 ms
Memory 3788 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 32
AC × 2
Set Name Test Cases
All sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 9 ms 3456 KB
sample_02.txt AC 2 ms 3452 KB
testcase_1.txt AC 2 ms 3524 KB
testcase_10.txt AC 2 ms 3596 KB
testcase_11.txt AC 2 ms 3492 KB
testcase_12.txt AC 2 ms 3520 KB
testcase_13.txt AC 2 ms 3600 KB
testcase_14.txt AC 3 ms 3460 KB
testcase_15.txt AC 16 ms 3724 KB
testcase_16.txt AC 7 ms 3720 KB
testcase_17.txt AC 10 ms 3720 KB
testcase_18.txt AC 5 ms 3728 KB
testcase_19.txt AC 4 ms 3676 KB
testcase_2.txt AC 1 ms 3456 KB
testcase_20.txt AC 4 ms 3596 KB
testcase_21.txt AC 8 ms 3652 KB
testcase_22.txt AC 11 ms 3728 KB
testcase_23.txt AC 3 ms 3552 KB
testcase_24.txt AC 11 ms 3728 KB
testcase_25.txt AC 12 ms 3728 KB
testcase_26.txt AC 10 ms 3788 KB
testcase_27.txt AC 7 ms 3580 KB
testcase_28.txt AC 5 ms 3584 KB
testcase_29.txt AC 2 ms 3476 KB
testcase_3.txt AC 2 ms 3444 KB
testcase_30.txt AC 3 ms 3688 KB
testcase_4.txt AC 2 ms 3572 KB
testcase_5.txt AC 2 ms 3596 KB
testcase_6.txt AC 2 ms 3520 KB
testcase_7.txt AC 3 ms 3592 KB
testcase_8.txt AC 2 ms 3408 KB
testcase_9.txt AC 2 ms 3492 KB