Submission #15578354


Source Code Expand

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

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' && i < n - 1) {
      int length = 0;
      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 / 2;
  }
  cout << answer << endl;
  return 0;
}

Submission Info

Submission Time
Task B - ニコニコ文字列
User Jonah00
Language C++ (GCC 9.2.1)
Score 0
Code Size 962 Byte
Status
Exec Time 12 ms
Memory 3852 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 3436 KB
subtask0_sample_02.txt 2 ms 3484 KB
subtask0_sample_03.txt 2 ms 3508 KB
subtask0_sample_04.txt 3 ms 3536 KB
subtask0_sample_05.txt 2 ms 3480 KB
subtask1_01.txt 2 ms 3512 KB
subtask1_02.txt 5 ms 3548 KB
subtask1_03.txt 2 ms 3552 KB
subtask1_04.txt 2 ms 3664 KB
subtask1_05.txt 2 ms 3520 KB
subtask1_06.txt 2 ms 3516 KB
subtask1_07.txt 2 ms 3596 KB
subtask1_08.txt 2 ms 3664 KB
subtask1_09.txt 2 ms 3604 KB
subtask1_10.txt 2 ms 3632 KB
subtask1_11.txt 2 ms 3564 KB
subtask1_12.txt 3 ms 3664 KB
subtask1_13.txt 2 ms 3540 KB
subtask2_01.txt 5 ms 3680 KB
subtask2_02.txt 9 ms 3788 KB
subtask2_03.txt 8 ms 3708 KB
subtask2_04.txt 7 ms 3848 KB
subtask2_05.txt 8 ms 3740 KB
subtask2_06.txt 7 ms 3760 KB
subtask2_07.txt 7 ms 3848 KB
subtask2_08.txt 12 ms 3852 KB
subtask2_09.txt 3 ms 3608 KB
subtask2_10.txt 2 ms 3636 KB
subtask2_11.txt 2 ms 3580 KB
subtask2_12.txt 2 ms 3584 KB