Submission #75428230


Source Code Expand

#line 2 "/Users/blue_jam/ProconLibrary/misc/template.hpp"

#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

#define ALL(x) (x).begin(), (x).end()

using ll = long long;
#ifndef EPS
const double eps = 1e-10;
#else
const double eps = EPS;
#endif
#line 2 "abc456/D/main.cpp"

const ll MOD = 998244353;
using mint = modint998244353;

void solve(std::string S) {
    ll N = S.size();
    vector dp(N + 1, vector<mint>(4));
    dp[0][3] = 1;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < 4; j++) {
            dp[i + 1][j] += dp[i][j];
        }
        ll c = S[i] - 'a';
        for (ll j = 0; j < 4; j++) {
            if (j == c) continue;
            dp[i + 1][c] += dp[i][j];
        }
    }
    cout << (dp[N][0] + dp[N][1] + dp[N][2]).val() << endl;
}

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

Submission Info

Submission Time
Task D - Not Adjacent 2
User blue_jam
Language C++23 (GCC 15.2.0)
Score 400
Code Size 941 Byte
Status AC
Exec Time 17 ms
Memory 20344 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 3572 KiB
random_01.txt AC 17 ms 20252 KiB
random_02.txt AC 13 ms 16088 KiB
random_03.txt AC 17 ms 20120 KiB
random_04.txt AC 7 ms 9820 KiB
random_05.txt AC 17 ms 20252 KiB
random_06.txt AC 7 ms 9388 KiB
random_07.txt AC 17 ms 20212 KiB
random_08.txt AC 6 ms 8928 KiB
random_09.txt AC 17 ms 20208 KiB
random_10.txt AC 13 ms 16808 KiB
random_11.txt AC 17 ms 20248 KiB
random_12.txt AC 2 ms 4572 KiB
random_13.txt AC 17 ms 20344 KiB
random_14.txt AC 13 ms 15856 KiB
random_15.txt AC 17 ms 20344 KiB
random_16.txt AC 7 ms 9160 KiB
random_17.txt AC 16 ms 20228 KiB
random_18.txt AC 11 ms 14280 KiB
random_19.txt AC 16 ms 20220 KiB
random_20.txt AC 5 ms 7116 KiB
random_21.txt AC 17 ms 20136 KiB
random_22.txt AC 11 ms 14076 KiB
random_23.txt AC 17 ms 20176 KiB
random_24.txt AC 3 ms 6184 KiB
random_25.txt AC 17 ms 20120 KiB
sample_01.txt AC 1 ms 3584 KiB
sample_02.txt AC 1 ms 3452 KiB