Submission #15578797


Source Code Expand

Copy
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;

const int N = 100010;
int dp[N];

signed main() {
  string s;
  cin >> s;

  int n = s.size();
  if(n <= 1) {
    cout << 0 << endl;
    return 0;
  }
  memset(dp, 0, sizeof(dp));

  int answer = 0;
  for (int i = 1; i < n; i++) {
    if(s[i - 1] == '2' && s[i] == '5') {
      if(i == 1) dp[i] = 1;
      else dp[i] += dp[i - 2] + 1;
    } else {
      dp[i] = 0;
    }
    answer += dp[i];
  }

  cout << answer << endl;
  return 0;
}

Submission Info

Submission Time
Task B - ニコニコ文字列
User Jonah00
Language C++ (GCC 9.2.1)
Score 100
Code Size 566 Byte
Status
Exec Time 13 ms
Memory 4108 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
Subtask1 30 / 30 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
All 70 / 70 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt 6 ms 4016 KB
subtask0_sample_02.txt 5 ms 3984 KB
subtask0_sample_03.txt 2 ms 3984 KB
subtask0_sample_04.txt 2 ms 3932 KB
subtask0_sample_05.txt 2 ms 4004 KB
subtask1_01.txt 2 ms 4024 KB
subtask1_02.txt 2 ms 3876 KB
subtask1_03.txt 3 ms 3972 KB
subtask1_04.txt 3 ms 3992 KB
subtask1_05.txt 2 ms 3868 KB
subtask1_06.txt 2 ms 3944 KB
subtask1_07.txt 1 ms 3996 KB
subtask1_08.txt 2 ms 3872 KB
subtask1_09.txt 2 ms 3988 KB
subtask1_10.txt 2 ms 3544 KB
subtask1_11.txt 2 ms 3840 KB
subtask1_12.txt 3 ms 3992 KB
subtask1_13.txt 2 ms 3896 KB
subtask2_01.txt 6 ms 4004 KB
subtask2_02.txt 7 ms 4072 KB
subtask2_03.txt 6 ms 4012 KB
subtask2_04.txt 7 ms 4088 KB
subtask2_05.txt 7 ms 4068 KB
subtask2_06.txt 6 ms 4108 KB
subtask2_07.txt 13 ms 3996 KB
subtask2_08.txt 9 ms 4032 KB
subtask2_09.txt 2 ms 3984 KB
subtask2_10.txt 2 ms 4036 KB
subtask2_11.txt 6 ms 4012 KB
subtask2_12.txt 2 ms 3964 KB