結果

問題 No.3458 Scores of Subsequence
コンテスト
ユーザー Carpenters-Cat
提出日時 2026-02-28 20:07:43
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 414 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 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
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0