| 比赛 | 
    “Asm.Def战记之夏威夷”杯 | 
    评测结果 | 
    AWWWWWWWWW | 
    | 题目名称 | 
    Asm.Def的验证码 | 
    最终得分 | 
    10 | 
    | 用户昵称 | 
    万千世界,吾为大主宰 | 
    运行时间 | 
    0.083 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    1.29 MiB  | 
    | 提交时间 | 
    2015-11-06 09:03:11 | 
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#include<deque>
#include<map>
#define ll long long
#define mod 1000000007
using namespace std;
int n,a[100001];
int l1,l2,r1,r2;
struct sd{
	int x,y,num;
}g[100001];
int main()
{
	freopen("asm_code.in","r",stdin);
	freopen("asm_code.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	l1=0;l2=0;r1=0;r2=0;
	int no=0;
	int p=1;int tot=0;
	for(int i=1;i<=n;i++)
	{
		no=i+1;
		while(a[i]==a[no])no++;
		tot++;
		g[tot].x=p;g[tot].y=no-1;g[tot].num=no-p;
		p=no;i=no-1;
	}
	ll ans=0;
	for(int i=1;i<=tot;i++)
	{
		if(i+3<=tot)
		{
			ans=(ans+(g[i].num*g[i+1].num%mod)*(g[i+2].num*g[i+3].num%mod))%mod;
		}
	}
	ans%=mod;
	printf("%lld\n",ans);
}