Submission #75452711


Source Code Expand

#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
const int mod=998244353;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    char S[300005];
    scanf("%s", S);
    long long n=strlen(S);
    vector<long long>dp(3,0);
    long long tot=0;
    for(int i=0;i<n;++i) {
        int idx;
        if(S[i]=='a') idx=0;
        else if(S[i]=='b') idx=1;
        else idx=2;
        long long nl=(tot+1)%mod;
        tot=(tot+nl-dp[idx])%mod;
        if(tot<0) tot+=mod;
        dp[idx]=nl;
    }
    printf("%lld\n", tot);
    return 0;
}

Submission Info

Submission Time
Task D - Not Adjacent 2
User Chen_Zhen_DY
Language C++23 (GCC 15.2.0)
Score 400
Code Size 655 Byte
Status AC
Exec Time 4 ms
Memory 4200 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
min.txt AC 1 ms 4152 KiB
random_01.txt AC 3 ms 4120 KiB
random_02.txt AC 3 ms 4104 KiB
random_03.txt AC 4 ms 4128 KiB
random_04.txt AC 2 ms 4128 KiB
random_05.txt AC 3 ms 4128 KiB
random_06.txt AC 2 ms 3996 KiB
random_07.txt AC 3 ms 4128 KiB
random_08.txt AC 2 ms 4128 KiB
random_09.txt AC 3 ms 4200 KiB
random_10.txt AC 3 ms 3996 KiB
random_11.txt AC 4 ms 4200 KiB
random_12.txt AC 1 ms 4200 KiB
random_13.txt AC 4 ms 4152 KiB
random_14.txt AC 3 ms 4200 KiB
random_15.txt AC 3 ms 4192 KiB
random_16.txt AC 2 ms 4064 KiB
random_17.txt AC 4 ms 3976 KiB
random_18.txt AC 3 ms 4128 KiB
random_19.txt AC 4 ms 3996 KiB
random_20.txt AC 2 ms 4200 KiB
random_21.txt AC 4 ms 4128 KiB
random_22.txt AC 3 ms 4128 KiB
random_23.txt AC 4 ms 4104 KiB
random_24.txt AC 2 ms 4200 KiB
random_25.txt AC 3 ms 4080 KiB
sample_01.txt AC 1 ms 4144 KiB
sample_02.txt AC 1 ms 4080 KiB