记录编号 301050 评测结果 AAAAAAAAAA
题目名称 [NOIP 2015PJ]求和 最终得分 100
用户昵称 Gravataropen the window 是否通过 通过
代码语言 C++ 运行时间 0.472 s
提交时间 2016-08-30 09:13:25 内存使用 1.78 MiB
显示代码纯文本
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
struct point
{
	int n,c,s;
}a[100001];
struct pop
{
	int l,r;
}b[100001];
int n,i,j,k,ror=1,t,m,ans;
int cmp(const point &p,const point &q)
{
	if (p.c==q.c) return p.n<q.n;
	 else return p.c<q.c;
}
int main()
{
	freopen("2015sum.in","r",stdin);
	freopen("2015sum.out","w",stdout);
    scanf("%d%d",&n,&m);
	for (i=1; i<=n; ++i) 
	{
		scanf("%d",&a[i].s);
		a[i].n=i;
	}
	for (i=1; i<=n; ++i) scanf("%d",&a[i].c);
	sort(a+1,a+n+1,cmp);
	while (ror<=n)
	{
		t++;
		b[t].l=ror;
		while (a[ror+1].c==a[ror].c) ror++;
        b[t].r=ror;
		ror++;
	}
	//for (i=1; i<=n; ++i) printf("%d %d %d\n",a[i].c,a[i].s,a[i].n);
	//for (i=1; i<=t; ++i) printf("%d %d\n",b[i].l,b[i].r);
	for (i=1; i<=t; ++i)
     for (j=b[i].l; j<b[i].r; ++j)
	  for (k=j+1; k<=b[i].r; ++k)
	  if ((a[j].n+a[k].n)%2==0)
	   ans=(ans+((a[j].n+a[k].n)%10007)*((a[j].s+a[k].s)%10007))%10007;
	printf("%d\n",ans);
	return 0;
}