結果
| 問題 |
No.1159 Sashiming String
|
| ユーザー |
|
| 提出日時 | 2020-08-12 18:20:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 471 bytes |
| コンパイル時間 | 795 ms |
| コンパイル使用メモリ | 73,376 KB |
| 最終ジャッジ日時 | 2025-01-12 21:28:36 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
typedef long long ll;
int main(){
string s;
cin >> s;
int n = s.length();
vector<int> v(n, 0);
for(int i = n-3; i >= 0; i--){
v[i] = s.substr(i,3)=="ing";
}
int res = accumulate(v.begin(), v.end(), 0);
ll ans = 0;
for(int i = 0; i < n; i++){
if(v[i]) res--;
if(s[i] == 'S') ans += res;
}
cout << ans << endl;
return 0;
}