记录编号 159189 评测结果 AAAAAAAAAA
题目名称 最终得分 100
用户昵称 Gravatarwolf. 是否通过 通过
代码语言 C++ 运行时间 0.742 s
提交时间 2015-04-20 12:03:11 内存使用 0.31 MiB
显示代码纯文本
#include<iostream>
#include<fstream>
#include<bitset>
#include<vector>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdio>
using namespace std;
#if defined wolf
const string ok="OK";
const string kk="	";
ofstream nnew("cowa.in",ios::app);
ifstream fin("cowa.in");
#define fout cout
#define Endl endl
#else
ifstream fin("cowa.in");
ofstream fout("cowa.out");
#endif
long long ans=0;
vector<int> TT;
vector<int> num;
void core(){
	int a=0,b=0;
	for(int i=TT.size()-1;i>=0;--i){
		//cout<<TT[i]<<kk<<a<<kk<<b<<endl;
		if(TT[i]==1){
			ans+=num[i]*b;
		}else{
			b+=num[i];
		}
		//cout<<TT[i]<<kk<<a<<kk<<b<<kk<<ans<<endl;
	}
}
int main(){
	int n;
	fin>>n;
	for(int i=0;i!=n;++i){
		char txt;
		fin>>txt;
		//cout<<txt<<endl;
		if(txt=='W'){
			/*cout<<ans<<endl;
			for(int i=0;i!=TT.size();++i){
				cout<<TT[i]<<" ";
			}
			cout<<endl;
			for(int i=0;i!=TT.size();++i){
				cout<<num[i]<<" ";
			}
			cout<<endl;*/
			core();
		}else if(txt=='O'){
			if(TT.size()!=0&&TT.back()==2){
				num.back()++;
			}else{
				TT.push_back(2);
				num.push_back(1);
			}
		}else{
			if(TT.size()!=0&&TT.back()==1){
				num.back()++;
			}else{
				TT.push_back(1);
				num.push_back(1);
			}
		}
	}
	fout<<ans<<endl;
	//-------------------------*/
	#if defined wolf
	cout<<endl<<(double)clock()/CLOCKS_PER_SEC<<'s'<<endl;
	#endif
	return 0;
}
//Designed by wolf
//Mon Apr 20 2015