結果

問題 No.1171 Runs in Subsequences
ユーザー ningenMe
提出日時 2020-08-15 03:12:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 191,716 KB
最終ジャッジ日時 2025-01-13 00:55:44
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
constexpr long long MOD = 1'000'000'007LL;
int main() {
    SPEED
    string S; cin >> S;
    array<ll,26> num={};
    ll acc=0,sum=0,ans = 0,one=1,pow2=1;
    for(int i=0; i < S.size(); ++i) {
        int c=S[i]-'a';
        ll cnt = one + acc + sum + (MOD - num[c]);

        ans += cnt;

        acc += cnt;

        sum += pow2;

        num[c]+= pow2;

        pow2 *= 2;
        pow2 %= MOD;

        if(i%3) {
            cnt %= MOD;
            ans %= MOD;
            acc %= MOD;
            sum %= MOD;
            num[c]%= MOD; 
        }
    }
    cout << ans%MOD << "\n";
    return 0;
}
0