結果
問題 |
No.1159 Sashiming String
|
ユーザー |
![]() |
提出日時 | 2020-08-12 00:12:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 7,086 ms |
コンパイル使用メモリ | 307,012 KB |
最終ジャッジ日時 | 2025-01-12 20:41:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; S = regex_replace(S, regex("ing"), " "); int N = S.size(); vector<long> R(N + 1); for (int i = 1; i < N + 1; i++) { R.at(i) = R.at(i - 1) + (S.at(i - 1) == ' '); } long ans = 0; for (int i = 0; i < N; i++) { if (S.at(i) == 'S') ans += R.at(N) - R.at(i); } cout << ans << "\n"; }