結果
| 問題 | No.3458 Scores of Subsequence |
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2026-02-28 14:42:44 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 397 bytes |
| 記録 | |
| コンパイル時間 | 837 ms |
| コンパイル使用メモリ | 77,752 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-02-28 14:42:51 |
| 合計ジャッジ時間 | 2,165 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <iostream>
#include <string>
#include <atcoder/modint>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
using namespace atcoder;
using mint = modint998244353;
int main() {
string s; cin >> s;
int n = s.length();
int cntM = 0, i;
mint ans = 0;
rep(i, n) {
if (s[i] == 'M') { cntM++; }
else { ans += mint(3).pow(cntM); }
}
cout << ans.val() << endl;
return 0;
}
startcpp