結果
問題 |
No.1171 Runs in Subsequences
|
ユーザー |
|
提出日時 | 2020-08-15 03:21:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 642 bytes |
コンパイル時間 | 3,644 ms |
コンパイル使用メモリ | 192,152 KB |
最終ジャッジ日時 | 2025-01-13 00:56:54 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 15 WA * 3 |
ソースコード
#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 << "\n"; return 0; }