QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#83775#2887. 区间矩阵乘法fengyuyue#AC ✓518ms354396kbC++143.4kb2023-03-03 14:25:462023-03-03 14:25:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-03 14:25:48]
  • 评测
  • 测评结果:AC
  • 用时:518ms
  • 内存:354396kb
  • [2023-03-03 14:25:46]
  • 提交

answer

#include<bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
#define gc getchar
#define pc putchar
#define pii pair<int,int>
#define pil pair<int,long long>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define For(i,l,r) for(int i=(l);i<=(r);i++)
#define IFor(i,r,l) for(int i=(r);i>=(l);i--)
#define for_son(u) for(int e=head[u];e;e=nxt[e])
#define eps (1e-8)
#define INF 0x3f3f3f3f

using namespace std;

char aa;

namespace ljh
{

namespace IO
{
//    const int SIZ=1<<20;
//    char ibuf[SIZ],*p1,*p2,obuf[SIZ],*p3=obuf;
//  #define gc() (p1==p2&&(p2=(p1=ibuf)+fread(ibuf,1,SIZ,stdin),p1==p2)?EOF:*p1++)
//  void pc(const char &c)
//  {
//      if(p3-obuf==SIZ) fwrite(obuf,1,SIZ,stdout),p3=obuf;
//      *p3++=c;
//  }
    int rd()
    {
        int x=0,f=1;
        char ch=gc();
        while(!isdigit(ch)){
            if(ch=='-') f=-1;
            ch=gc();
        }
        while(isdigit(ch)){
            x=x*10+ch-'0';
            ch=gc();
        }
        return x*f;
    }
    void wr(int x,char ch)
    {
        if(x<0) x=-x,pc('-');
        static char st[12];
        int top=0;
        do{
            st[top++]=x%10+'0',x/=10;
        }while(x);
        while(top) pc(st[--top]);
        pc(ch);
    }
    ll ll_rd()
    {
        ll x=0;
        int f=1;
        char ch=gc();
        while(!isdigit(ch)){
            if(ch=='-') f=-1;
            ch=gc();
        }
        while(isdigit(ch)){
            x=x*10+ch-'0';
            ch=gc();
        }
        return x*f;
    }
    void ll_wr(ll x,char ch)
    {
        if(x<0) x=-x,pc('-');
        static char st[22];
        int top=0;
        do{
            st[top++]=x%10+'0',x/=10;
        }while(x);
        while(top) pc(st[--top]);
        pc(ch);
    }
}

using namespace IO;

const int N=2e5+5,D=455,mod=0;

namespace tem
{
//  void add_edge(int u,int v){nxt[++cnt]=head[u],to[cnt]=v,head[u]=cnt;}
    int qpow(int a,int b,int p)
    {
        a%=p;
        int res=1;
        while(b){
            if(b&1) res=1ll*res*a%p;
            a=1ll*a*a%p;
            b>>=1;
        }
        return res;
    }
    int get_inv(int x){return qpow(x,mod-2,mod);}
    int lowbit(int x){return x&(-x);}
    void add(int &x,const int y){ x=(x+y>=mod?x+y-mod:x+y); }
//  int get(int x) {return fa[x]==x?x:fa[x]=get(fa[x])};
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    int lcm(int a,int b){return a/gcd(a,b)*b;}
}

using namespace tem;

int n,m;
unsigned int s1[N],s2[D][N],a[N];

void main()
{
	n=rd();
	For(i,1,n) a[i]=rd(),s1[i]=s1[i-1]+a[i];
	For(d,1,n/d){
		For(i,1,n){
			s2[d][i]=i<=d?a[i]:s2[d][i-d]+a[i];
		}
	}
	m=rd();
	while(m--){
		int d=rd(),p1=rd(),p2=rd();
		unsigned int ans=0;
		For(j,0,d-1){
			ans+=(s2[d][p1+d*(d-1)+j]-(p1+j<=d?0:s2[d][p1+j-d]))*(s1[p2+d*j+d-1]-s1[p2+d*j-1]);
		}
		printf("%u\n",ans);
	}
//  fwrite(obuf,1,p3-obuf,stdout);
}

/*
5
2 2 1 2 1
4
1 5 4
2 2 1
2 1 1
1 5 5

*/

}

char bb;

int main()
{
//  freopen("1.in","r",stdin);
//  freopen("1.out","w",stdout);    
//  int st=clock();
    ljh::main();
//  int ed=clock();
//  cerr<<ed-st<<"ms"<<endl;
//      cerr<<(&bb-&aa)/1024/1024<<"MB"<<endl;
//  fclose(stdin);
//  fclose(stdout);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 3576kb

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

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: 518ms
memory: 354364kb

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: 484ms
memory: 354360kb

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: 460ms
memory: 354244kb

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

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: 376ms
memory: 354352kb

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: 418ms
memory: 354356kb

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: 298ms
memory: 354396kb

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: 342ms
memory: 354396kb

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