結果
| 問題 |
No.2419 MMA文字列2
|
| コンテスト | |
| ユーザー |
LaFolia13
|
| 提出日時 | 2023-07-29 17:06:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 636 bytes |
| コンパイル時間 | 1,530 ms |
| コンパイル使用メモリ | 171,352 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-08 04:31:24 |
| 合計ジャッジ時間 | 2,884 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;
#define ALL(x) x.begin(), x.end()
constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;
int main() {
string S;
cin >> S;
vector<vector<llong>> dp(3, vector<llong>(26));
for (int i = 0; i < 26; i++) {
dp[0][i] = 1;
}
llong ans = 0;
for (auto s: S) {
for (int i = 0; i < 26; i++) {
if ('A' + i != s) {
ans += dp[2][i];
}
}
for (int i = 2; i > 0; i--) {
dp[i][s - 'A'] += dp[i-1][s - 'A'];
}
}
cout << ans << endl;
return 0;
}
LaFolia13