QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22942#2887. 区间矩阵乘法ha114514ha#AC ✓383ms357644kbC++203.0kb2022-03-11 11:33:042022-04-30 02:09: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:09:29]
  • 评测
  • 测评结果:AC
  • 用时:383ms
  • 内存:357644kb
  • [2022-03-11 11:33:04]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
#pragma GCC optimize(3)
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define ui unsigned int
namespace IO_BUFF{
	mt19937 rnd(time(0)^(ll)(new char));
	int rend(int x){
		return rnd()%x+1;
	}
	void rendom_shuffle(int *a,int len){
		shuffle(a+1,a+len+1,rnd);
	}
	const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
	inline int gc(){
	    if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
	    return (HD==TL)?EOF:*HD++;
	}
	inline int inn(){
	    int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
	    while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
	}
	char ssss[19999999],tttt[20];int ssl,ttl;
    inline int print(int x)
    {
        if(x<0)ssss[++ssl]='-',x=(-x);
		if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
    }
	inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
	int read(){
		char c=getchar();int x=1;int s=0;
		while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
		while(c>='0' && c<='9'){
			s=s*10+c-'0';c=getchar();
		}
		return s*x;
	}
}using namespace IO_BUFF;
/*namespace CFConTest{
	const int mod=998244353;
	inline int add(const int &x,const int &y){
		return (x+y>=mod?x+y-mod:x+y);
	}
	inline int del(const int &x,const int &y){
		return (x-y<0?x-y+mod:x-y);
	}
	int ksm(int x,int k){
		int base=1;
		while(k){
			if(k&1)base=1ll*base*x%mod;
			k>>=1;
			x=1ll*x*x%mod;
		}
		return base;
	}
};
using namespace CFConTest;*/
const int N=2e5+55;
ui n,a[N],m,x,y,z;
ui s[N];
ui d[600][N];
signed main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		s[i]=s[i-1]+a[i];
	}
	for(int i=1;i*i<=n;i++){
		for(int k=1;k<=n;k++){
			if(k-i>=1){
				d[i][k]=d[i][k-i]-a[k-i];
			}
			else{
				for(int j=k;j<=n;j+=i){
					d[i][k]+=a[j];
				}
			}
		}
	}
	m=read();
	for(int i=1;i<=m;i++){
		x=read();y=read();z=read();
		ui ans=0;
		for(int k=0;k<x;k++){
			if(y+k+x*x<=n){
				ans+=(s[z+x*k+x-1]-s[z+x*k-1])*(d[x][y+k]-d[x][y+k+x*(x)]);
			}
			else{
				ans+=(s[z+x*k+x-1]-s[z+x*k-1])*(d[x][y+k]);
			}
		}
		cout<<ans<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 341ms
memory: 356992kb

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: 351ms
memory: 356876kb

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: 348ms
memory: 357644kb

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: 368ms
memory: 356968kb

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: 383ms
memory: 356992kb

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: 341ms
memory: 354940kb

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: 352ms
memory: 356876kb

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: 367ms
memory: 357096kb

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: 356ms
memory: 356956kb

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