結果

問題 No.1171 Runs in Subsequences
ユーザー pockynypockyny
提出日時 2020-08-14 22:16:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 580 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 70,528 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-04-18 22:06:50
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 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 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
typedef long long ll;
ll mod = 1000000007,ans = 0;
ll solve[200010],solve2[200010],sum[30] = {};
int main(){
    string s; cin >> s;
    int i,n = s.size();
    ll inv = (mod + 1)/2;
    solve[0] = 1; solve2[0] = 1;
    for(i=1;i<=n;i++) solve[i] = inv*solve[i - 1]%mod;
    for(i=1;i<=n;i++) solve2[i] = 2*solve2[i - 1]%mod;
    for(i=0;i<n;i++){
        int j = s[i] - 'a';
        (ans += (1 - solve[i]*sum[j]%mod + mod)%mod*inv%mod) %= mod;
        sum[j] += solve2[i];
    }
    cout << ans*solve2[n]%mod << endl;
}
0