結果

問題 No.346 チワワ数え上げ問題
ユーザー progressing7
提出日時 2016-02-27 20:12:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 377 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 58,624 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 11:46:58
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	string s; cin >> s;
	auto cit = find(s.begin(), s.end(),'c');
	int ans = 0;

	while (true) {
		int wcnt = count(cit, s.end(), 'w');
		if (wcnt != 0) {
			ans += (wcnt*(wcnt - 1) / 2);
			cit = find(cit + 1, s.end(), 'c');
		} else {
			break;
		}
	}
	cout << ans << endl;
	return 0;
}
0