結果
| 問題 | 
                            No.346 チワワ数え上げ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             springroll
                         | 
                    
| 提出日時 | 2018-11-13 22:40:07 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 413 bytes | 
| コンパイル時間 | 1,506 ms | 
| コンパイル使用メモリ | 166,968 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-24 13:29:34 | 
| 合計ジャッジ時間 | 2,706 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 WA * 9 | 
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	string t;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'c' || s[i] == 'w') {
			t.push_back(s[i]);
		}
	}
	int n=t.length(), cntw=0;
	int ans=0;
	for (int i = n - 1; i >= 0; i--) {
		if (t[i] == 'w') {
			cntw++;
		}
		if (t[i] == 'c') {
			ans += cntw*(cntw-1)/2;
		}
	}
	cout << ans << endl;
}
            
            
            
        
            
springroll