记录编号 159200 评测结果 AAAAAAAAAA
题目名称 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 0.007 s
提交时间 2015-04-20 12:07:10 内存使用 0.26 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <algorithm>
#include <cmath>
using namespace std;
//#define USEFREAD
#ifdef USEFREAD
#define InputLen 5000000
char *ptr=(char *)malloc(InputLen);
#define getc() (*(ptr++))
#else
#define getc() (getchar())
#endif
#define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout))
template<class T>inline void getd(T &x){
    char ch = getc();bool neg = false;
    while(!isdigit(ch) && ch != '-')ch = getc();
    if(ch == '-')ch = getc(), neg = true;
    x = ch - '0';
    while(isdigit(ch = getc()))x = x * 10 - '0' + ch;
    if(neg)x = -x;
}
/***********************************************************************/
const int maxn = 100005;
typedef long long LL;

int main(){
	#ifdef DEBUG
	freopen("test.txt", "r", stdin);
	#else       
	SetFile(cowa);
	#endif
	#ifdef USEFREAD
	fread(ptr,1,InputLen,stdin);
	#endif
	char ch[maxn], *it = ch, *end;
	int N, i;
	LL f[3] = {0};
	getd(N);end = ch + N;
	while(!isalpha(*it = getc()));
	for(++it;it != end;++it)*it = getc();
	if(*ch == 'C')*f = 1;
	for(i = 1, it = ch + 1;i < N;++i, ++it){
		if(*it == 'C')++*f;
		else if(*it == 'O')f[1] += *f;
		else f[2] += f[1];
	}
	printf("%lld\n", f[2]);
	
#ifdef DEBUG
    printf("\n%.3lf sec \n", (double)clock() / CLOCKS_PER_SEC);
#endif
    return 0;
}