結果

問題 No.346 チワワ数え上げ問題
ユーザー masa
提出日時 2016-02-26 22:36:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 441 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 59,424 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 14:12:00
合計ジャッジ時間 6,994 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {
	string s, t;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'c' || s[i] == 'w') {
			t += s[i];
		}
	}

	s = t;

	long long ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'c') {
			continue;
		}
		long long nw = count(s.begin() + i, s.end(), 'w');
		ans += nw * (nw - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}
0