結果
| 問題 | No.3458 Scores of Subsequence |
| コンテスト | |
| ユーザー |
Treewhitetree
|
| 提出日時 | 2026-02-28 14:03:21 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 626 bytes |
| 記録 | |
| コンパイル時間 | 3,790 ms |
| コンパイル使用メモリ | 334,440 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-02-28 14:03:27 |
| 合計ジャッジ時間 | 4,549 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename T>bool chmax(T &x, T y){if(x>=y)return false;x=y;return true;}
template<typename T>bool chmin(T &x, T y){if(x<=y)return false;x=y;return true;}
const long long mod = 998244353;
long long modpow(long long n, long long r){
long long ans = 1;
while(r){
if(r%2)ans = ans * n % mod;
n = n * n % mod;
r /= 2;
}
return ans;
}
int main(){
long long ans = 0, c = 0;
string S;
cin >> S;
for(auto x: S){
if(x=='M')c++;
else ans = (ans+modpow(3, c))%mod;
}
cout << ans << endl;
}
Treewhitetree