QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#208422#7561. Digit DPmasterhuangWA 462ms17432kbC++202.7kb2023-10-09 16:17:102023-10-09 16:17:11

Judging History

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

  • [2023-10-09 16:17:11]
  • 评测
  • 测评结果:WA
  • 用时:462ms
  • 内存:17432kb
  • [2023-10-09 16:17:10]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define bll __int128
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
inline int rd()
{
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
inline bll rd1()
{
	bll x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') x=x*2+ch-'0',ch=getchar();
	return x;
}
const int N=2e7+5,mod=998244353,I6=(mod+1)/6;
int n,q,rt,a[105],tot;
inline int md(int x){return x>=mod?x-mod:x;}
struct node
{
	int s0,s1,s2,s3;
	inline node operator+(node X){return {md(s0+X.s0),md(s1+X.s1),md(s2+X.s2),md(s3+X.s3)};}
	inline node operator+(int x){return {s0,(s1+1ll*s0*x)%mod,(s2+1ll*s0*x%mod*x+2ll*s1*x)%mod,
	(s3+1ll*s0*x%mod*x%mod*x+3*(1ll*s1*x%mod*x+1ll*s2*x))%mod};}
	inline int que(){return ((2ll*s3-3ll*s1*s2+1ll*s1*s1%mod*s1)%mod+mod)*I6%mod;}
}b[105];
struct tree{int ls,rs,lt;node t;}c[N];
#define ls c[wz].ls
#define rs c[wz].rs
inline void init(bll l,bll r,int &wz)
{
	bll s=1;int t,S=0;for(int i=0;;i++,s<<=1) if(s==r-l+1){t=i;break;}
	for(int i=0;i<n;i++) if(l>>i&1) S=md(S+a[i]);c[wz=++tot].t=b[t]+S;
//	cout<<(LL)l<<" "<<(LL)r<<" "<<t<<":\n";
//	cout<<c[wz].t.s0<<" "<<c[wz].t.s1<<" "<<c[wz].t.s2<<" "<<c[wz].t.s3<<"\n";
}
inline void upd(int wz,int x){c[wz].lt+=x,c[wz].t=c[wz].t+x;}
inline void pushdown(bll l,bll r,bll mid,int wz)
{
	if(!ls) init(l,mid,ls);if(!rs) init(mid+1,r,rs);
	int t=c[wz].lt;if(t) upd(ls,t),upd(rs,t),c[wz].lt=0;
}
void updata(bll l,bll r,int &wz,bll L,bll R,int x)
{
	if(!wz) init(l,r,wz);
	if(L<=l&&r<=R) return upd(wz,x);bll mid=(l+r)>>1;pushdown(l,r,mid,wz);
	if(L<=mid) updata(l,mid,ls,L,R,x);
	if(mid<R) updata(mid+1,r,rs,L,R,x);c[wz].t=c[ls].t+c[rs].t;
}
node query(bll l,bll r,int &wz,bll L,bll R)
{
	if(L<=l&&r<=R) return (!wz)&&(init(l,r,wz),1),c[wz].t;
	if(!wz) return {(r-l+1)%mod,0,0,0};
	bll mid=(l+r)>>1;pushdown(l,r,mid,wz);
	if(L<=mid&&mid<R) return query(l,mid,ls,L,R)+query(mid+1,r,rs,L,R);
	if(L<=mid) return query(l,mid,ls,L,R);return query(mid+1,r,rs,L,R);
}
int cs[10];
int main()
{
	n=rd(),q=rd();for(int i=0;i<n;i++) a[i]=rd();
//	for(int i=0;i<(1<<n);i++)
//	{
//		for(int j=0;j<n;j++) if(i>>j&1) cs[i]+=a[j];
//		cout<<cs[i]<<" "; 
//	}cout<<"\n";
	b[0]={1,0,0,0};
	for(int i=1;i<=n;i++) b[i]=b[i-1]+(b[i-1]+a[i-1]);bll U=((bll)1)<<n;
//	for(int i=0;i<=n;i++) cout<<b[i].s1<<" ";cout<<"\n";
	while(q--)
	{
		int o=rd();bll l=rd1(),r=rd1();
		if(o==1) updata(0,U-1,rt,l,r,rd());
		else cout<<query(0,U-1,rt,l,r).que()<<"\n";
	}
	return 0;
}
/*
3 3
1 2 4
2 000 111
1 010 101 1
2 000 111
*/

詳細信息

Test #1:

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

input:

3 3
1 2 4
2 000 111
1 010 101 1
2 000 111

output:

1960
3040

result:

ok 2 number(s): "1960 3040"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3436kb

input:

2 2
1 1
2 00 10
2 00 11

output:

0
2

result:

ok 2 number(s): "0 2"

Test #3:

score: 0
Accepted
time: 462ms
memory: 14652kb

input:

99 49952
470888 74578 802746 396295 386884 721198 628655 722503 207868 647942 87506 792718 761498 917727 843338 908043 952768 268783 375312 414369 319712 96230 277106 168102 263554 936674 246545 667941 198849 268921 191459 436316 134606 802932 515506 837311 465964 394766 17626 650419 984050 790137 4...

output:

413449847
513027341
379532803
828185770
758023792
955841012
501590435
193833160
52015005
225646848
79278417
702315659
500712121
309545833
425668668
376205546
751940860
216608361
71293362
894788412
240680508
127400767
584610664
427310971
447134022
992309654
109125715
611523032
601028580
647705121
222...

result:

ok 24939 numbers

Test #4:

score: 0
Accepted
time: 430ms
memory: 10304kb

input:

99 49996
475634 928248 927808 875072 158867 937890 595515 26685 468307 240390 887597 586447 764525 365644 156469 188306 350786 308832 695957 562147 427221 937909 590963 478310 357775 361535 993561 967811 718075 555000 533750 412453 936715 173340 350235 67386 20497 895277 233727 235830 182535 324591 ...

output:

259953307
262069796
924406695
26478563
298108385
704809872
792095151
692313907
142605670
903738194
553847857
38647574
43984176
29033158
867129569
773316503
446446137
689917105
416630991
420951134
458731790
810982529
271786324
784672540
32086643
884115047
362416513
759279937
954942112
657139797
84271...

result:

ok 24966 numbers

Test #5:

score: -100
Wrong Answer
time: 461ms
memory: 17432kb

input:

97 49937
288891 590429 244358 321145 930851 89174 529670 363571 728747 543238 720391 188689 702144 813561 628383 660056 781508 605777 759705 485733 534730 812292 937524 788519 451996 10588 483682 267682 461493 65270 619145 355885 963015 800644 217669 264757 640439 685387 674020 853944 91420 891750 5...

output:

0
0
0
0
121175554
920857234
690801029
201407028
945021685
635573900
216040077
104774110
355850561
561273301
926775110
372974907
597614504
942178785
379372329
754110414
735461091
710022471
323330013
717895783
482511705
946821704
625188740
299932888
895004295
367564320
584354070
561158178
7891734
6979...

result:

wrong answer 1st numbers differ - expected: '965092014', found: '0'