結果

問題 No.346 チワワ数え上げ問題
ユーザー Haar
提出日時 2016-04-13 01:30:05
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 402 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 56,156 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 06:38:48
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main() {
	int w_cnt=0, temp, sum;
	string str;
	
	cin >> str;
	for(int i=0;i<str.length();++i)if(str[i]=='w')++w_cnt;
	
	temp = sum = 0;
	for(int i=0;i<str.length();++i){
		if(str[i] == 'w'){
			++temp;
		}else if(str[i] == 'c'){
			w_cnt -= temp;
			sum += w_cnt * (w_cnt - 1) / 2;
			temp = 0;
		}
	}
	cout << sum << endl;
	
	return 0;
}
0