結果
問題 |
No.346 チワワ数え上げ問題
|
ユーザー |
![]() |
提出日時 | 2017-09-28 12:53:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 738 bytes |
コンパイル時間 | 692 ms |
コンパイル使用メモリ | 82,336 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 18:13:17 |
合計ジャッジ時間 | 1,567 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; int main() { string S; cin >> S; vector<int> W(S.length()+1); W[S.length()] = 0; for ( int i = S.length()-1; i >= 0; i-- ) { if ( S[i] == 'w' ) { W[i] = W[i+1]+1; } else { W[i] = W[i+1]; } } long long ans = 0; for ( int i = 0; i < S.length(); i++ ) { if ( S[i] == 'c' ) { ans += W[i+1] * (W[i+1]-1) / 2; } } cout << ans << endl; return 0; }