QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418464#8717. 骰子tzxydby#RE 0ms4100kbC++141.8kb2024-05-23 14:05:442024-05-23 14:05:45

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 14:05:45]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:4100kb
  • [2024-05-23 14:05:44]
  • 提交

answer

#include<cstdio>
#include<cstring>
#define mo 1000000007
using namespace std;
int n,m,q,in1,in2,b[210],p[1510][210],res[210];
inline int MO(int x)
{
	return x<mo?x:x-mo;
}
inline void wk(int* a,int* b,int* c)
{
	memset(a,0,sizeof(int)*(m+1));
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j+i<=m;j++)
		{
			a[i+j]=MO(a[i+j]+1ll*b[i]*c[j]%mo);
		}
	}
}
struct node
{
	int **dat;
	node *lch,*rch;
	node(int l,int r)
	{
		if(l==r)
		{
			dat=nullptr;
			return;
		}
		dat=new int*[r-l+1];
		for(int i=0;i<=r-l;i++)
		{
			dat[i]=new int[m+1];
		}
		int md=l+r>>1;
		memcpy(dat[md-l],p[md],sizeof(int)*(m+1));
		memcpy(dat[md+1-l],p[md+1],sizeof(int)*(m+1));
		for(int i=md-1;i>=l;i--)
		{
			wk(dat[i-l],dat[i-l+1],p[i]);
		}
		for(int i=md+2;i<=r;i++)
		{
			wk(dat[i-l],dat[i-l-1],p[i]);
		}
		lch=new node(l,md);
		rch=new node(md+1,r);
	}
	inline int wkot(int x,int y,int l,int r)
	{
		int md=l+r>>1;
		if(x==md+1)
		{
			int ans=0;
			for(int i=0;i<=m;i++)
			{
				ans=MO(ans+1ll*b[i]*dat[y-l][i]%mo);
			}
			return ans;
		}
		else if(y==md)
		{
			int ans=0;
			for(int i=0;i<=m;i++)
			{
				ans=MO(ans+1ll*b[i]*dat[x-l][i]%mo);
			}
			return ans;
		}
		else if(x<=md&&y>md)
		{
			int ans=0;
			wk(res,dat[x-l],dat[y-l]);
			for(int i=0;i<=m;i++)
			{
				ans=MO(ans+1ll*b[i]*res[i]%mo);
			}
			return ans;
		}
		else return y<md?lch->wkot(x,y,l,md):rch->wkot(x,y,md+1,r);
	}
};
node *no;
int main()
{
	scanf("%d%d%d",&n,&m,&q);
	for(int i=0;i<=m;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			scanf("%d",&p[i][j]);
		}
	}
	no=new node(1,n);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&in1,&in2);
		printf("%d\n",no->wkot(in1,in2,1,n));
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

3 3 3
4 3 2 1
0 1 0 1000000007
0 500000004 0 500000004
0 0 500000004 500000004
1 1
1 2
1 3

output:

3
1
0

result:

ok 3 number(s): "3 1 0"

Test #2:

score: 0
Accepted
time: 0ms
memory: 4100kb

input:

3 3 6
4 3 2 1
1000000007 0 1 0
1000000007 1 0 0
1000000007 0 1 0
1 1
1 2
1 3
2 2
2 3
3 3

output:

2
1
0
3
1
2

result:

ok 6 numbers

Test #3:

score: -100
Runtime Error

input:

1 1 1
604063100 57375033
742299910 257700098
1 1

output:


result: