結果

問題 No.346 チワワ数え上げ問題
ユーザー elphe
提出日時 2024-11-12 15:09:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 67,836 KB
最終ジャッジ日時 2025-02-25 04:00:06
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	int64_t ans = 0;
	for (int32_t i = S.size() - 1, count = 0; i != -1; --i)
		switch (S[i])
		{
		case 'w':
			++count;
			break;

		case 'c':
			ans += count * static_cast<int64_t>(count - 1) / 2;
			break;
		}

	cout << ans << '\n';
	return 0;
}
0