結果

問題 No.3458 Scores of Subsequence
コンテスト
ユーザー Carpenters-Cat
提出日時 2026-02-28 20:05:49
言語 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
結果
WA  
実行時間 -
コード長 439 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,757 ms
コンパイル使用メモリ 277,332 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-02-28 20:05:56
合計ジャッジ時間 6,630 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 7 WA * 18
権限があれば一括ダウンロードができます

ソースコード

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] + ((mint)2).pow(i);
	}
	mint ans = 0;
	int c = 0;
	for (auto& a : s) {
		if (a == 'M') {
			c ++;
		} else {
			ans += pw[c];
			c = 0;
		}
	}
	cout << ans.val() << endl;
}
0