結果
| 問題 |
No.1171 Runs in Subsequences
|
| コンテスト | |
| ユーザー |
otogawa
|
| 提出日時 | 2025-04-22 04:02:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 652 bytes |
| コンパイル時間 | 2,495 ms |
| コンパイル使用メモリ | 195,756 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-22 04:02:17 |
| 合計ジャッジ時間 | 4,268 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int ll
using ll = long long;
const int MOD = 1e9 + 7;
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
string s;
cin >> s;
int n = s.size();
vector<int> cnt(26), dp(26);
int tot = 0, pot = 1;
for (int i = 0; i < n; i++) {
int ans = tot + 1;
for (int j = 0; j < 26; j++) {
if (s[i] - 'a' != j) ans = (ans + cnt[j]) % MOD;
}
dp[s[i] - 'a'] = (dp[s[i] - 'a'] + ans) % MOD;
cnt[s[i] - 'a'] = (cnt[s[i] - 'a'] + pot) % MOD;
pot = pot*2 % MOD;
tot = (tot + ans) % MOD;
}
cout << tot << endl;
}
otogawa