結果

問題 No.346 チワワ数え上げ問題
ユーザー willowoooo
提出日時 2016-05-15 21:52:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 63,712 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-06 04:08:38
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> c, w;
	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'c')
			c.push_back(i);
		else if (s[i] == 'w')
			w.push_back(i);
	}
	for (int i = 0; i < c.size(); i++)
	{
		auto it = lower_bound(w.begin(), w.end(), c[i]);
		int count =  distance(it, w.end());
		ans += count * (count -1) / 2;
	}
	cout << ans << endl;
	return 0;
}
0