Submission #15578510


Source Code Expand

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

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

  int n = s.size();
  vector<int> cnt(n + 1);

  for (int i = 0; i < n;) {
    if(s[i] == '2') {
      int length = 0;
      if(i == n - 1) break;
      for (int j = i + 1; j < n; j++) {
        if(j % 2 != i % 2 && s[j] == '5') {
          length++;
          if(j == n - 1) {
            cnt[length]++;
            i = j;
            break;
          }
        } else if(j % 2 == i % 2 && s[i] == '2') {
          if(j == n - 1) {
            cnt[length]++;
            i = j;
            break;
          }
          continue;
        } else {
          cnt[length]++;
          i = j;
          break;
        }
      }
    } else {
      i++;
    }
  }
  int answer = 0;
  for (int i = 1; i <= n; i++) {
    answer += cnt[i] * (i + 1) * i / 2LL;
  }
  cout << answer << endl;
  return 0;
}

Submission Info

Submission Time
Task B - ニコニコ文字列
User Jonah00
Language C++ (GCC 9.2.1)
Score 0
Code Size 1003 Byte
Status
Exec Time 9 ms
Memory 4288 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 0 / 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 0 / 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 9 ms 3464 KB
subtask0_sample_02.txt 2 ms 3572 KB
subtask0_sample_03.txt 2 ms 3568 KB
subtask0_sample_04.txt 2 ms 3444 KB
subtask0_sample_05.txt 4 ms 3556 KB
subtask1_01.txt 2 ms 3616 KB
subtask1_02.txt 2 ms 3564 KB
subtask1_03.txt 2 ms 3440 KB
subtask1_04.txt 2 ms 3480 KB
subtask1_05.txt 2 ms 3612 KB
subtask1_06.txt 2 ms 3432 KB
subtask1_07.txt 2 ms 3492 KB
subtask1_08.txt 2 ms 3624 KB
subtask1_09.txt 2 ms 3548 KB
subtask1_10.txt 2 ms 3464 KB
subtask1_11.txt 2 ms 3560 KB
subtask1_12.txt 2 ms 3556 KB
subtask1_13.txt 2 ms 3576 KB
subtask2_01.txt 9 ms 4184 KB
subtask2_02.txt 8 ms 4188 KB
subtask2_03.txt 4 ms 4112 KB
subtask2_04.txt 9 ms 4180 KB
subtask2_05.txt 9 ms 4160 KB
subtask2_06.txt 6 ms 4160 KB
subtask2_07.txt 6 ms 4220 KB
subtask2_08.txt 4 ms 4288 KB
subtask2_09.txt 2 ms 3672 KB
subtask2_10.txt 2 ms 3676 KB
subtask2_11.txt 2 ms 3672 KB
subtask2_12.txt 2 ms 3676 KB