QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22958#2887. 区间矩阵乘法LFCode#TL 3ms5596kbC++14991b2022-03-11 12:21:212022-04-30 02:10:52

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:52]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:5596kb
  • [2022-03-11 12:21:21]
  • 提交

answer

//什么时候我才能有杜爷一半强啊/kk
#include<iostream>
#include<cstdio>
using namespace std;
const int N=202086,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(){
	//freopen("F.in","r",stdin);
	//freopen("F.out","w",stdout);
	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]-f[x+i-1+k*k][k])*(s[y+i*k-1]-s[y+(i-1)*k-1]);
			//printf("aa %d %d\n",i,ans);
		}
		cout<<ans<<'\n';
	}
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 5596kb

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:

4189305368
55181820
2129409470
700818946
3501766645
1730563858
3899557935
4020833941
1896225959
3402813306
1636148212
106070907
1868972913
406568818
4117597926
65997073
3713307242
3060762232
2968862403
705700646
1131106229
4118099190
420297313
2760229439
4118078127
4042393869
1482472642
1219344853
3...

result: