結果
問題 |
No.1171 Runs in Subsequences
|
ユーザー |
|
提出日時 | 2025-07-02 09:39:24 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 633 bytes |
コンパイル時間 | 3,176 ms |
コンパイル使用メモリ | 278,708 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-07-02 09:39:29 |
合計ジャッジ時間 | 4,677 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; sum %= md, cnt %= md; 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 % md, cnt % md}; } int ans = 0; for(int i = 0; i < 26; i++) { ans += dp[i].first; ans %= md; } cout << ans << "\n"; }