結果

問題 No.2419 MMA文字列2
ユーザー うえこうえこ
提出日時 2023-08-12 14:02:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 173,904 KB
実行使用メモリ 295,680 KB
最終ジャッジ日時 2024-04-30 04:47:32
合計ジャッジ時間 8,711 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 113 ms
68,864 KB
testcase_13 AC 19 ms
13,696 KB
testcase_14 AC 249 ms
129,024 KB
testcase_15 AC 134 ms
80,512 KB
testcase_16 AC 262 ms
134,912 KB
testcase_17 AC 68 ms
42,496 KB
testcase_18 AC 274 ms
140,928 KB
testcase_19 AC 279 ms
144,896 KB
testcase_20 AC 77 ms
47,488 KB
testcase_21 AC 54 ms
34,304 KB
testcase_22 AC 490 ms
295,596 KB
testcase_23 AC 488 ms
295,680 KB
testcase_24 AC 487 ms
295,664 KB
testcase_25 AC 486 ms
295,552 KB
testcase_26 AC 61 ms
38,272 KB
testcase_27 AC 482 ms
295,552 KB
testcase_28 AC 486 ms
295,544 KB
testcase_29 AC 483 ms
295,628 KB
testcase_30 AC 484 ms
295,680 KB
testcase_31 AC 483 ms
295,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
int main(){
    std::string s;
    std::cin >> s;
    int n=s.size();
    std::vector<std::vector<std::vector<long long>>>dp(n+1,std::vector<std::vector<long long>>(26,std::vector<long long>(3)));
    for(int i=0;i<n;++i){
        for(int j=0;j<26;++j){
            //k=0;
            dp[i+1][j][0]=dp[i][j][0];
            if(j==s[i]-'A')++dp[i+1][j][0];
            
            //k=1
            dp[i+1][j][1]=dp[i][j][1];
            if(j==s[i]-'A'){
                dp[i+1][j][1]+=dp[i][j][0];
            }
            
            //k=2
            dp[i+1][j][2]=dp[i][j][2];
            if(j==s[i]-'A'){
                for(int m=0;m<26;++m){
                    if(j==m)continue;
                    dp[i+1][j][2]+=dp[i][m][1];
                }
            }
        }
    }
    long long ans=0;
    for(int i=0;i<26;++i){
        ans+=dp.back()[i][2];
    }
    std::cout << ans << '\n';
}
0