結果

問題 No.1171 Runs in Subsequences
ユーザー vjudge1
提出日時 2025-09-02 17:02:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 1,651 ms
コンパイル使用メモリ 163,092 KB
実行使用メモリ 15,940 KB
最終ジャッジ日時 2025-09-02 17:02:26
合計ジャッジ時間 5,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 1 WA * 10 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int dp[200005], n;
int main(){
    string s;
    cin >> s;
    n = s.size();
    s.insert(0, " ");
    for(int i = 1; i <= n; i++){
        dp[i] = 1;
        for(int j = i - 1; j >= 1; j--){
            if(s[i] == s[j]) dp[i] = (dp[i] + dp[j]) % M;
            else dp[i] = (0LL + dp[i] + dp[j] * 2) % M;
        }
    }
    int ans = 0;
    // for(int i = 1; i <= n; i++) cout << dp[i] << " \n"[i == n];
    for(int i = 1; i <= n; i++) ans = (ans + dp[i]) % M;
    cout << ans;
    return 0;
}
0