比赛 |
“Asm.Def战记之夏威夷”杯 |
评测结果 |
AAAAAAAAAA |
题目名称 |
Asm.Def的验证码 |
最终得分 |
100 |
用户昵称 |
Asm.Def |
运行时间 |
0.006 s |
代码语言 |
C++ |
内存使用 |
5.06 MiB |
提交时间 |
2015-11-06 13:59:27 |
显示代码纯文本
/*****************************************************************************/
/******************************Designed By Asm.Def****************************/
/*****************************************************************************/
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cctype>
#include <ctime>
#define SetFile(x) (freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout) )
#define FREAD
#define FREADLENTH 5000000
#ifdef FREAD
char *fread_ptr = (char*)malloc(FREADLENTH);
#define getc() (*(fread_ptr++))
#else
#define getc() getchar()
#endif
using namespace std;
template<class T>inline void getd(T &x){
int ch = getc();bool neg = false;
while(!isdigit(ch) && ch != '-')ch = getc();
if(ch == '-')neg = true, ch = getc();
x = ch - '0';
while(isdigit(ch = getc()))x = x * 10 - '0' + ch;
if(neg)x = -x;
}
/*******************************************************************************/
const int maxn = 100004, mod = 1000000007;
inline void calc(){
int N, t, i;
int S1[2] = {0}, S2[2] = {0}, S3[2] = {0}, S4[2] = {0};
getd(N);
while(N--){
getd(t);--t;
i = t ^ 1;
++S1[t];
S2[t] += S1[i];if(S2[t] >= mod)S2[t] -= mod;
S3[t] += S2[i];if(S3[t] >= mod)S3[t] -= mod;
S4[t] += S3[i];if(S4[t] >= mod)S4[t] -= mod;
}
S4[0] += S4[1];if(S4[0] >= mod)S4[0] -= mod;
printf("%d\n", S4[0]);
}
int main(){
#ifdef DEBUG
freopen("test.txt", "r", stdin);
#else
SetFile(asm_code);
#endif
#ifdef FREAD
fread(fread_ptr, 1, FREADLENTH, stdin);
#endif
calc();
#ifdef DEBUG
printf("\n%.3lf sec\n", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}