結果

問題 No.346 チワワ数え上げ問題
ユーザー fiord
提出日時 2016-02-26 23:16:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 1,431 ms
コンパイル使用メモリ 159,884 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 23:07:08
合計ジャッジ時間 2,088 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;	cin>>s;
	int n=s.size();
	ll ccnt=0,wcnt=0;
	for(int i=0;i<n;i++)	if(s[i]=='w')	wcnt++;
	ll ans=0;
	for(int i=0;i<n;i++){
		if(s[i]=='c')	ccnt++;
		else if(s[i]=='w'){
			wcnt--;
			ans+=ccnt*wcnt;
		}
	}
	cout<<ans<<endl;
	return 0;
}
0