結果

問題 No.1159 Sashiming String
ユーザー DaYuanChiDaYuanChi
提出日時 2021-04-02 00:26:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 4,788 KB
最終ジャッジ日時 2023-08-23 07:20:30
合計ジャッジ時間 2,385 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll a[200005];

int main(){
  string s; cin >> s;
  vector<int> t;
  for(int i = 0; i < s.size(); i++){
    if(s[i]=='S') t.push_back(0);
    if(s[i]=='i' && s[i+1]=='n' && s[i+2]=='g') t.push_back(1);
  }
  int n = t.size();
  int cnt = 0;
  for(int i = n-1; i>=0; i--){
    if(t[i]==1) cnt++;
    a[i] = cnt;
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    if(t[i]==0) ans += a[i];
  }
  cout << ans << endl;
  return 0;
} 
0