Submission #14842170


Source Code Expand

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


void solve(string S){
  ll cnt = 0;
  ll ans = 0;
  for(int i=0; i<S.size(); i++) {
    if(i+1 < S.size() and S[i] == '2' and S[i+1] == '5') {
      cnt++;
      i++;
    } else {
      ans += cnt*(cnt+1)/2;
      cnt = 0;
    }
  }
  ans += cnt*(cnt+1)/2;
  std::cout << ans << std::endl;
}

int main(){
  string S;
  cin>>S;
  solve(S);
  return 0;
}

Submission Info

Submission Time
Task B - ニコニコ文字列
User y_tsune
Language C++ (GCC 9.2.1)
Score 100
Code Size 466 Byte
Status
Exec Time 8 ms
Memory 3840 KB

Compile Error

./Main.cpp: In function ‘void solve(std::string)’:
./Main.cpp:10:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   10 |   for(int i=0; i<S.size(); i++) {
      |                ~^~~~~~~~~
./Main.cpp:11:12: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   11 |     if(i+1 < S.size() and S[i] == '2' and S[i+1] == '5') {
      |        ~~~~^~~~~~~~~~

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 3532 KB
subtask0_sample_02.txt 4 ms 3532 KB
subtask0_sample_03.txt 3 ms 3556 KB
subtask0_sample_04.txt 2 ms 3576 KB
subtask0_sample_05.txt 2 ms 3608 KB
subtask1_01.txt 2 ms 3624 KB
subtask1_02.txt 2 ms 3600 KB
subtask1_03.txt 2 ms 3552 KB
subtask1_04.txt 3 ms 3604 KB
subtask1_05.txt 2 ms 3492 KB
subtask1_06.txt 2 ms 3552 KB
subtask1_07.txt 2 ms 3588 KB
subtask1_08.txt 2 ms 3496 KB
subtask1_09.txt 2 ms 3492 KB
subtask1_10.txt 2 ms 3604 KB
subtask1_11.txt 3 ms 3584 KB
subtask1_12.txt 2 ms 3588 KB
subtask1_13.txt 2 ms 3584 KB
subtask2_01.txt 7 ms 3800 KB
subtask2_02.txt 4 ms 3824 KB
subtask2_03.txt 5 ms 3832 KB
subtask2_04.txt 5 ms 3840 KB
subtask2_05.txt 7 ms 3752 KB
subtask2_06.txt 3 ms 3748 KB
subtask2_07.txt 8 ms 3796 KB
subtask2_08.txt 6 ms 3692 KB
subtask2_09.txt 2 ms 3616 KB
subtask2_10.txt 2 ms 3492 KB
subtask2_11.txt 2 ms 3492 KB
subtask2_12.txt 2 ms 3492 KB