結果
問題 |
No.1171 Runs in Subsequences
|
ユーザー |
|
提出日時 | 2025-07-02 09:38:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 2,945 ms |
コンパイル使用メモリ | 278,520 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-07-02 09:38:21 |
合計ジャッジ時間 | 4,644 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int K = 26; const int md = 1e9 + 7; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); string S; cin >> S; vector<pair<int,int>> dp(K); for(char ch: S) { auto[sum, cnt] = dp[ch - 'a']; sum += sum; cnt += cnt; for(int j = 0; j < 26; j++) if(ch - 'a' != j) { cnt += dp[j].second; sum += dp[j].first + dp[j].second; cnt %= md, sum %= md; } sum += 1, cnt += 1; dp[ch - 'a'] = {sum, cnt}; } int ans = 0; for(int i = 0; i < 26; i++) { ans += dp[i].first; ans %= md; } cout << ans << "\n"; }