QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#22946#2887. 区间矩阵乘法WhybullYMe#AC ✓983ms356976kbC++20939b2022-03-11 11:47:032022-04-30 02:09:46

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:09:46]
  • 评测
  • 测评结果:AC
  • 用时:983ms
  • 内存:356976kb
  • [2022-03-11 11:47:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ri int
typedef long long ll;
const int maxn=2e5+3,maxp=450;
template<class T>inline bool ckmin(T &x,const T &y){return x>y?x=y,1:0;}
template<class T>inline bool ckmax(T &x,const T &y){return x<y?x=y,1:0;}
template<class T>inline void clear(T *arr,int siz,int val=0){memset(arr,val,sizeof(T)*(siz+1));}
int a[maxn],m,mx,n;
// sum_j sum[p1+j][d]*(pre[p2+d*(j+1)-1]-pre[p2+d*j-1])
unsigned int pre[maxn],sum[maxn][maxp];
int main(){
	scanf("%d",&n);
	mx=sqrt(n+1);
	for(ri i=1;i<=n;++i)scanf("%d",a+i),pre[i]=pre[i-1]+a[i];
	for(ri i=n;i;--i)
		for(ri j=1;j<=mx;++j){
			sum[i][j]=(i+j<=n?sum[i+j][j]:0)+a[i];
			if(i+j*j<=n)sum[i][j]-=a[i+j*j];
		}
	scanf("%d",&m);
	while(m--){
		ri d,p1,p2;
		scanf("%d%d%d",&d,&p1,&p2);
		unsigned int ans=0;
		for(ri j=0;j<d;++j)ans+=sum[p1+j][d]*(pre[p2+d*(j+1)-1]-pre[p2+d*j-1]);
		printf("%lld\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

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

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: 0
Accepted
time: 862ms
memory: 356976kb

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:

ok 200000 lines

Test #3:

score: 0
Accepted
time: 853ms
memory: 356760kb

input:

199991
50488 111471 32277 186986 111719 44110 11281 151267 185070 84519 8443 105449 172375 100199 51046 131999 27105 36794 127996 10891 105017 41651 170616 195528 39040 45220 76177 101436 85812 108372 169961 87651 129738 97809 171813 13735 163174 107481 46668 135209 42809 94937 38234 115576 25350 10...

output:

2845573307
3316581267
1268193698
3150875092
990142828
1076596713
2242790675
1307809975
3511746665
3257129545
2430646995
1762372575
1595993008
3881316467
3850941329
26688989
421735204
4107269928
2395625027
1741953640
1678378588
2909204613
2995349464
622489233
1862573541
1648707903
1113411840
24957975...

result:

ok 199990 lines

Test #4:

score: 0
Accepted
time: 848ms
memory: 356768kb

input:

200000
5 5 4 2 1 4 4 2 5 1 4 4 4 2 5 5 5 2 1 4 2 3 5 4 3 2 1 3 5 2 1 3 3 4 4 3 1 3 2 1 4 4 3 4 3 1 1 4 3 5 1 2 3 5 3 2 3 5 2 3 2 5 2 5 3 4 2 4 4 1 3 2 4 4 2 1 4 4 3 5 1 1 1 1 5 5 4 3 3 1 4 3 3 2 5 4 2 5 2 1 2 1 2 5 2 1 2 5 1 1 2 1 3 3 2 1 2 4 2 1 4 3 4 1 3 1 3 4 2 4 3 4 1 2 3 5 1 4 1 1 5 2 4 3 3 3 4...

output:

234044624
131294120
351527392
123228682
258515471
234121262
32725835
6154022
544239400
801071622
693038164
5918593
245969162
442632662
46065237
76629963
59038616
727870004
2600655
6571029
163018129
31823463
733383070
263135686
702709157
435550667
86531707
10983443
613369401
16053033
10
153125575
129...

result:

ok 200000 lines

Test #5:

score: 0
Accepted
time: 819ms
memory: 356912kb

input:

200000
172508 37245 4341 110730 33249 7934 48980 60882 61133 181187 159547 180156 19811 128032 49096 98584 152071 184143 37372 121784 193229 101625 62952 181191 103485 79759 89868 4289 24403 163533 61599 191993 190068 38800 14053 94622 35339 28455 53306 56602 27995 10032 190476 21259 148497 133715 1...

output:

2304554177
2113652836
2698482189
940286339
1169901206
2884650184
3241982532
2449564844
440043869
347337077
1046026872
2232041949
565384720
4027818842
28790908
1630825809
1505354661
836450079
4014508474
1735439892
759871090
3944933661
3908260772
1570947216
3554381164
1710935202
207445420
429459442
31...

result:

ok 200000 lines

Test #6:

score: 0
Accepted
time: 855ms
memory: 356840kb

input:

200000
94273 21601 65295 72296 156414 124314 134780 74084 98232 35466 92298 91634 74939 151664 67313 89982 193330 28378 96040 199119 176567 135668 88985 129555 72548 58118 148242 77737 24856 199682 129337 69436 130320 109824 127768 135881 167354 161116 140018 152116 96631 162417 53518 90355 144056 1...

output:

3709698421
1226280072
2162367382
1091443591
1587830230
4210810659
3201932025
796973027
1145185078
1295477708
985315152
2821773757
4132550860
1820453458
885625294
1285740234
438516239
2478186647
1621486339
735969296
1435114436
2698727123
2895122896
2597785269
2463725898
3905490172
1551563742
17233190...

result:

ok 200000 lines

Test #7:

score: 0
Accepted
time: 983ms
memory: 356900kb

input:

200000
74230 73829 86276 19224 178370 11590 165137 52324 59305 169971 37525 13699 18549 174905 195068 27747 59875 190559 1514 176019 59061 138987 23969 130632 24004 31528 105035 152075 84379 159146 80489 79946 110424 124108 32023 81916 91850 112099 19174 102577 141563 92424 148808 190023 138217 9497...

output:

947562840
2180010341
2958317260
4250791548
3405312498
2579953637
3681716495
1534557473
2029403198
21748325
494216717
3427107095
1613138475
2814193617
2743948969
4285232828
850294681
2980914380
1893870312
634143675
1989508749
2795699459
540067696
2509964229
4044232045
1763068901
1151096267
483336909
...

result:

ok 200000 lines

Test #8:

score: 0
Accepted
time: 874ms
memory: 356768kb

input:

200000
71099 86628 173324 15671 186729 55092 66595 165674 5083 142720 3488 29039 126873 161274 78180 109912 155983 50422 167704 149672 14315 103854 16037 155344 2610 154225 17073 98706 22125 156506 122650 156858 61849 173108 66200 130234 114443 67000 178808 45520 11443 123127 38090 190389 61968 9864...

output:

1512146777
3001096603
3020394656
3097719235
397888161
2579125770
3146861152
252702708
62450546
609579688
745768402
3159667160
429481671
3699262822
997809880
3660480415
3624187538
3932406758
2454674993
2893000239
3850440772
2056925679
3873998709
1278784767
2733969641
3569143367
791826573
768415856
16...

result:

ok 200000 lines

Test #9:

score: 0
Accepted
time: 970ms
memory: 356900kb

input:

200000
9363 159910 184012 193374 52303 169231 50656 98974 186114 104704 106342 194237 75533 162521 44845 42140 8840 28971 139507 15010 23469 2036 199127 157508 5338 179624 144338 124644 2098 106697 69174 615 187030 5911 26980 11772 63790 30988 180563 77542 102258 64403 119741 41180 82129 152316 1183...

output:

1141180645
2922528465
2988721363
2206570840
3947069198
426198710
78684746
869694385
3963444519
336827985
2655872106
722404982
4135352988
3736666101
2969907699
1723056739
209980963
1423339501
4100859045
3552559527
4171422773
3290749071
1047836123
3858420659
2009583850
2048201576
1024256693
3006143360...

result:

ok 200000 lines

Test #10:

score: 0
Accepted
time: 853ms
memory: 356856kb

input:

200000
107853 187729 14521 9393 152800 23961 141946 133535 60289 38272 27891 195324 76910 86753 85555 127354 112134 151561 65152 145390 168278 102226 88446 68962 172368 77903 97129 146549 137453 103350 32623 12979 2922 110489 92485 70603 102296 139000 70872 159955 46452 77154 102683 108096 57293 559...

output:

3959167320
2721628540
1280622714
1908638606
3538601169
1452731466
2469983505
1639083666
2575658805
1847964972
1532777267
2234789001
2933373712
3555863259
108438220
3462534362
4100507604
2503288043
747854626
1738347594
4091121922
2530392208
887168622
658798714
3798524267
3808286224
4067212739
3616244...

result:

ok 200000 lines