提出 #75432566


ソースコード 拡げる

// Date: 2026-05-02
#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
    bool debug_mode = 1;
#else
    bool debug_mode = 0;
#endif

using ll = long long;
#define cerr if(debug_mode) cerr

int main() {
    cin.tie(0) -> sync_with_stdio(0);

    const int MOD = 998244353;
    
    string s; cin >> s;
    int n = s.size();

    vector<int> dp(n + 1);
    int current_dp_sum = 0;
    int dp_type[26] = {};

    for (int i = 0; i < n; i++) {
        dp[i] += (((current_dp_sum - dp_type[s[i] - 'a']) % MOD + MOD) % MOD + 1) % MOD;

        current_dp_sum += dp[i];
        current_dp_sum %= MOD;

        dp_type[s[i] - 'a'] += dp[i];
        dp_type[s[i] - 'a'] %= MOD;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += dp[i];
        ans %= MOD;
    }

    cout << ans;
}

提出情報

提出日時
問題 D - Not Adjacent 2
ユーザ Emmetthor
言語 C++ IOI-Style(GNU++20) (GCC 14.2.0)
得点 400
コード長 847 Byte
結果 AC
実行時間 7 ms
メモリ 3340 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 28
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
min.txt AC 0 ms 1704 KiB
random_01.txt AC 7 ms 3340 KiB
random_02.txt AC 5 ms 2984 KiB
random_03.txt AC 6 ms 3336 KiB
random_04.txt AC 3 ms 2472 KiB
random_05.txt AC 6 ms 3336 KiB
random_06.txt AC 2 ms 2344 KiB
random_07.txt AC 6 ms 3336 KiB
random_08.txt AC 2 ms 2344 KiB
random_09.txt AC 6 ms 3340 KiB
random_10.txt AC 5 ms 2984 KiB
random_11.txt AC 6 ms 3340 KiB
random_12.txt AC 1 ms 1832 KiB
random_13.txt AC 7 ms 3336 KiB
random_14.txt AC 5 ms 2984 KiB
random_15.txt AC 7 ms 3340 KiB
random_16.txt AC 3 ms 2344 KiB
random_17.txt AC 7 ms 3340 KiB
random_18.txt AC 4 ms 2856 KiB
random_19.txt AC 7 ms 3336 KiB
random_20.txt AC 2 ms 2216 KiB
random_21.txt AC 7 ms 3340 KiB
random_22.txt AC 4 ms 2856 KiB
random_23.txt AC 7 ms 3336 KiB
random_24.txt AC 1 ms 2088 KiB
random_25.txt AC 7 ms 3336 KiB
sample_01.txt AC 1 ms 1704 KiB
sample_02.txt AC 0 ms 1704 KiB