結果

問題 No.1171 Runs in Subsequences
ユーザー V_Melville
提出日時 2025-09-03 14:57:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 5,254 ms
コンパイル使用メモリ 335,148 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-03 14:57:10
合計ジャッジ時間 6,808 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using mint = modint1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    
    vector<mint> two(n+1, 1);
    rep(i, n) two[i+1] = two[i]*2;
    
    mint ans;
    vector<mint> dp(26);
    rep(i, n) {
        ans += (two[i]-dp[s[i]-'a']) * two[n-1-i];
        dp[s[i]-'a'] += two[i];
    }
    
    cout << ans.val() << '\n';
    
    return 0;
}
0