結果
| 問題 | No.3458 Scores of Subsequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 20:07:43 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 2,000 ms |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 4,978 ms |
| コンパイル使用メモリ | 277,312 KB |
| 実行使用メモリ | 7,976 KB |
| 最終ジャッジ日時 | 2026-02-28 20:07:50 |
| 合計ジャッジ時間 | 6,753 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge7 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
int main () {
string s;
cin >> s;
int N = s.size();
std::vector<mint> pw(N);
pw[0] = 1;
for (int i = 1; i < N; i ++) {
pw[i] = pw[i-1] * 3;
}
mint ans = 0;
int c = 0;
for (auto& a : s) {
if (a == 'M') {
c ++;
} else {
ans += pw[c];
}
}
cout << ans.val() << endl;
}