結果
| 問題 |
No.1171 Runs in Subsequences
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-15 03:22:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 646 bytes |
| コンパイル時間 | 2,039 ms |
| コンパイル使用メモリ | 192,504 KB |
| 最終ジャッジ日時 | 2025-01-13 00:57:04 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1'000'000'007LL;
int main() {
cin.tie(0);ios::sync_with_stdio(false);
string S; cin >> S;
array<ll,26> num={};
ll acc=0,sum=0,ans=0,pow2=1;
int i=1;
for(char& a:S) {
int c=a-'a';
ll cnt = 1 + acc + sum + (MOD - num[c]);
ans += cnt;
acc += cnt;
sum += pow2;
num[c]+= pow2;
pow2 *= 2;
if(!((i+=1)%5))continue;
ans %= MOD;
acc %= MOD;
sum %= MOD;
num[c]%= MOD;
pow2 %= MOD;
}
cout << ans%MOD << "\n";
return 0;
}