結果

問題 No.2419 MMA文字列2
ユーザー HIcoderHIcoder
提出日時 2023-08-21 12:28:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 1,100 ms
コンパイル使用メモリ 108,704 KB
実行使用メモリ 205,056 KB
最終ジャッジ日時 2024-05-08 17:47:09
合計ジャッジ時間 5,442 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 55 ms
48,384 KB
testcase_13 AC 9 ms
10,496 KB
testcase_14 AC 110 ms
89,984 KB
testcase_15 AC 64 ms
56,576 KB
testcase_16 AC 116 ms
94,080 KB
testcase_17 AC 33 ms
30,208 KB
testcase_18 AC 120 ms
98,176 KB
testcase_19 AC 123 ms
100,992 KB
testcase_20 AC 38 ms
33,920 KB
testcase_21 AC 27 ms
24,576 KB
testcase_22 AC 234 ms
205,056 KB
testcase_23 AC 235 ms
204,988 KB
testcase_24 AC 234 ms
205,008 KB
testcase_25 AC 235 ms
204,932 KB
testcase_26 AC 30 ms
27,392 KB
testcase_27 AC 232 ms
205,028 KB
testcase_28 AC 235 ms
204,940 KB
testcase_29 AC 234 ms
205,004 KB
testcase_30 AC 234 ms
204,928 KB
testcase_31 AC 236 ms
204,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<tuple>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;


int main(){
    string S;
    cin>>S;
    int N=S.size();

    vector dp(N+1,vector<vector<ll>>(4,vector<ll>(26,0)));



    /*
    for(int c=0;c<26;c++){
        dp[0][0][c]=1;
    }
    */

    for(int i=0;i<N;i++){
        for(int c=0;c<26;c++){
            //dp[i+1][0][c] +=dp[i][0][c];
            //dp[i+1][1][S[i]-'A']+=dp[i][0][c];
            
            if(S[i]-'A'==c){
                dp[i+1][1][c]+=1;
            }

            dp[i+1][1][c]+=dp[i][1][c];
            if(S[i]-'A'==c){
                dp[i+1][2][c]+=dp[i][1][c];
            }

            dp[i+1][2][c]+=dp[i][2][c];

            if(S[i]-'A'!=c){
                dp[i+1][3][S[i]-'A']+=dp[i][2][c];
            }

            dp[i+1][3][c]+=dp[i][3][c];
        }
    }

    ll ans=0;
    for(int c=0;c<26;c++){
        ans+=dp[N][3][c];
    }

    cout<<ans<<endl;


}
0