結果

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main() {

	string a;
	cin>>a;
	vector<long long int>x(a.size());

	for(int i=a.size()-1;i>=0;i--){

		if(a[i]=='w')x[i]++;
		if(i)x[i-1]+=x[i];

	}
	long long int y=0;
	for(int i=0;i<a.size();i++){

		if(a[i]=='c'){
			if(x[i]>=2){
				y+=(x[i]-1)*(x[i])/2;
			}
		}

	}
	cout<<y<<endl;

	
	

	return 0;
}

	
0