提出 #71124452


ソースコード 拡げる

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

const int Maxn=1e6+6;
char S[Maxn];
int ans;

int main(){
    scanf("%s",S+1);
    int n=strlen(S+1);

    for(int i=1,j;i<=n;i=j+1){
        j=i;
        while(j<n and S[j+1]==S[i]) ++j;
        int k=j+1;
        while(k<n and S[k+1]==S[j+1]) ++k;
        if(k<=n){
            int l1=j-i+1,l2=k-j;
            if(S[i]+1==S[k]) ans+=min(l1,l2);
        }
    }
    cout<<ans;

    return 0;
}

提出情報

提出日時
問題 C - 1122 Substring 2
ユーザ AceTaffy_
言語 C++23 (GCC 15.2.0)
得点 300
コード長 487 Byte
結果 AC
実行時間 9 ms
メモリ 4900 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 4
AC × 23
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3800 KiB
00_sample_01.txt AC 1 ms 3764 KiB
00_sample_02.txt AC 1 ms 3868 KiB
00_sample_03.txt AC 1 ms 3732 KiB
01_random_00.txt AC 1 ms 3800 KiB
01_random_01.txt AC 3 ms 4604 KiB
01_random_02.txt AC 3 ms 4604 KiB
01_random_03.txt AC 3 ms 4604 KiB
01_random_04.txt AC 3 ms 4824 KiB
01_random_05.txt AC 3 ms 4684 KiB
01_random_06.txt AC 6 ms 4436 KiB
01_random_07.txt AC 6 ms 4748 KiB
01_random_08.txt AC 3 ms 4124 KiB
01_random_09.txt AC 9 ms 4800 KiB
01_random_10.txt AC 8 ms 4748 KiB
01_random_11.txt AC 8 ms 4772 KiB
01_random_12.txt AC 8 ms 4684 KiB
01_random_13.txt AC 5 ms 4748 KiB
01_random_14.txt AC 5 ms 4824 KiB
01_random_15.txt AC 6 ms 4900 KiB
01_random_16.txt AC 6 ms 4860 KiB
01_random_17.txt AC 5 ms 4864 KiB
01_random_18.txt AC 5 ms 4764 KiB