結果

問題 No.1159 Sashiming String
ユーザー ninoinuininoinui
提出日時 2020-08-12 00:12:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 8,458 ms
コンパイル使用メモリ 307,336 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 17:56:22
合計ジャッジ時間 6,728 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 7 ms
5,376 KB
testcase_03 AC 13 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 7 ms
5,376 KB
testcase_07 AC 10 ms
5,376 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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