結果
| 問題 | No.1171 Runs in Subsequences |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-03 14:57:03 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| + 682µs | |
| コード長 | 513 bytes |
| 記録 | |
| コンパイル時間 | 3,952 ms |
| コンパイル使用メモリ | 376,408 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-14 13:46:53 |
| 合計ジャッジ時間 | 5,521 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using mint = modint1000000007;
int main() {
string s;
cin >> s;
int n = s.size();
vector<mint> two(n+1, 1);
rep(i, n) two[i+1] = two[i]*2;
mint ans;
vector<mint> dp(26);
rep(i, n) {
ans += (two[i]-dp[s[i]-'a']) * two[n-1-i];
dp[s[i]-'a'] += two[i];
}
cout << ans.val() << '\n';
return 0;
}