QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22953#2887. 区间矩阵乘法LFCode#TL 1ms1824kbC++14868b2022-03-11 12:09:292022-04-30 02:10:29

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 02:10:29]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:1824kb
  • [2022-03-11 12:09:29]
  • 提交

answer

//什么时候我才能有杜爷一半强啊/kk
#include<cstdio>
const int N=200086,B=455;
int n,a[N];
unsigned int s[N],f[N][B];
int read(){
	char ch=getchar();int nn=0,ssss=1;
	while(ch<'0'||ch>'9'){if(ch=='-')ssss*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){nn=nn*10+(ch-'0');ch=getchar();}
	return nn*ssss;
}
int main(){
	n=read();int B=1;while((B+1)*(B+1)<=n)B++;
	for(int i=1;i<=n;i++){
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	for(int j=1;j<=B;j++){
		for(int i=n;i>=n-j+1;i--)f[i][j]=a[i];
		for(int i=n-j;i>0;i--)f[i][j]=f[i+j][j]+a[i];
		for(int i=1;i+j*j<=n;i++)f[i][j]-=f[i+j*j][j];
	}
	int m=read();
	for(int o=1;o<=m;o++){
		int k=read();int x=read();int y=read();
		unsigned int ans=0;
		for(int i=1;i<=k;i++){
			ans+=f[x+i-1][k]*(s[y+i*k-1]-s[y+(i-1)*k-1]);
			//printf("aa %d %d\n",i,ans);
		}
		printf("%u\n",ans);
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 1824kb

input:

8
1 2 2 2 2 2 1 1
2
2 2 2
1 3 7

output:

32
2

result:

ok 2 lines

Test #2:

score: -100
Time Limit Exceeded

input:

200000
110569 155 159393 154631 169597 134901 75060 60085 189794 169502 10184 170809 170894 5697 83892 99814 97985 11604 39943 171446 77088 44463 60432 121559 54578 115592 151722 115322 147103 126168 55464 42044 181426 196809 58680 173065 136429 76030 109558 78475 161094 46875 1564 177386 108053 828...

output:


result: