結果
問題 |
No.1171 Runs in Subsequences
|
ユーザー |
👑 ![]() |
提出日時 | 2020-10-07 16:32:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 521 bytes |
コンパイル時間 | 1,889 ms |
コンパイル使用メモリ | 166,344 KB |
実行使用メモリ | 6,940 KB |
最終ジャッジ日時 | 2024-07-20 03:26:44 |
合計ジャッジ時間 | 2,964 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using LL=long long; using ULL=unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ULL M=1000000007; ULL C[128]={}; ULL powM2[200001]; ULL powMI2[200001]; ULL ans=0; string S; int N; int main(){ cin>>S; N=S.size(); powM2[0]=powMI2[0]=1; rep(i,N) powM2[i+1]=powM2[i]*2%M; rep(i,N) powMI2[i+1]=powMI2[i]*500000004%M; rep(i,N){ char c=S[i]; ans = ans*2%M; ans = (ans+powM2[i]+M-C[c])%M; C[c]=(C[c]+powM2[i])%M; } cout<<ans<<endl; return 0; }