QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#841739#7488. 人人本着正义之名Crysfly100 ✓5752ms249332kbC++144.2kb2025-01-03 23:49:152025-01-03 23:49:16

Judging History

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

  • [2025-01-03 23:49:16]
  • 评测
  • 测评结果:100
  • 用时:5752ms
  • 内存:249332kb
  • [2025-01-03 23:49:15]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
char buf[1<<21],*p1=buf,*p2=buf;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
#define N 4200005
#define inf 0x3f3f3f3f
int n,m,a[3000005],tot;
#define sum(p) (p?p->sum:0)
#define cnt(p) (p?p->cnt:0)
#define ml(p,v) (p?p->ml[v]:inf)
struct node{
	int l,r,sum,cnt,ml[2],ld[2],rd[2],qwq;
	bool v;node*ls,*rs;
	inline void pushup(){
		sum=sum(ls)+sum(rs)+(r-l+1)*v;
		cnt=cnt(ls)+cnt(rs)+v;
		ml[v]=min(min(ml(ls,v),ml(rs,v)),r-l+1);
		ml[!v]=min(ml(ls,!v),ml(rs,!v));
	}
	inline void pusht(int lld0,int lld1,int rrd0,int rrd1){
		ld[0]+=lld0,ld[1]+=lld1,rd[0]+=rrd0,rd[1]+=rrd1;
		ml[0]+=rrd0-lld0,ml[1]+=rrd1-lld1;
		sum+=(rrd1-lld1)*cnt;
		if(v)l+=lld1,r+=rrd1;
		else l+=lld0,r+=rrd0;
	}
	inline void pushdown(){
		if(!ld[0]&&! rd[0]&&! ld[1]&&! rd[1])return;
		if(ls)ls->pusht(ld[0], ld[1], rd[0], rd[1]);
		if(rs)rs->pusht(ld[0], ld[1], rd[0], rd[1]);
		ld[0]=rd[0]=ld[1]=rd[1]=0;
	}
};
node*rt;
node st[N];
inline node* newn(int l,int r,bool v){
    if(l>r)return NULL;
    node*p=&st[++tot];
	p->l=l,p->r=r,p->v=v;
	p->sum=(r-l+1)*v,p->cnt=v;
	p->ml[v]=r-l+1,p->ml[!v]=inf,p->qwq=rand();
    return p;
}

void splitl(node*p,int v,node*&x,node*&y)
{
	if(!p)return x=y=NULL,void();
	p->pushdown();
	if(p->r<v)x=p,splitl(p->rs,v,p->rs,y);
	else y=p,splitl(p->ls,v,x,p->ls);
	p->pushup();
}
void splitr(node*p,int v,node*&x,node*&y)
{
	if(!p)return x=y=NULL,void();
	p->pushdown();
	if(p->l<=v)x=p,splitr(p->rs,v,p->rs,y);
	else y=p,splitr(p->ls,v,x,p->ls);
	p->pushup();
}
node* merge(node* x,node* y){
	if(!x)return y; if(!y)return x;
	if(x->qwq < y->qwq)return x->pushdown(),x->rs=merge(x->rs,y),x->pushup(),x;
	return y->pushdown(),y->ls=merge(x,y->ls),y->pushup(),y;
}
inline node* findl(node* x){
    while(x->ls)x=x->ls;
	return x;
}
inline node* findr(node* x){
    while(x->rs)x=x->rs;
	return x;
}
void assign(int l,int r,bool v)
{
	node *x,*y,*z;
	splitl(rt,l,x,y),splitr(y,r,y,z);
	node *pl=findl(y),*pr=findr(y);
	if(pl->v==v)l=pl->l;
	else x=merge(x,newn(pl->l,l-1,pl->v));
	if(pr->v==v)r=pr->r;
	else z=merge(newn(r+1,pr->r,pr->v),z);
	if(x&&(pl=findr(x))->v==v) splitl(x,l=pl->l,x,pl);
	if(z&&(pr=findl(z))->v==v) r=pr->r,splitl(z,r+1,pr,z);
	rt=merge(merge(x,newn(l,r,v)),z);
}
void move(int l,int r,int ld0,int ld1,int rd0,int rd1,bool qwq)
{
	node *x,*y,*z;
	splitl(rt,l,x,y),splitr(y,r,y,z);
	node *pl=findl(y),*pr=findr(y);
	if(pl->v==qwq){
		splitr(y,pl->l,pl,y),x=merge(x,pl);
		if(!y)return rt=merge(x,z),void();
	}
	if(pr->v!=qwq){
		splitl(y,pr->l,y,pr),z=merge(pr,z);
		if(!y)return rt=merge(x,z),void();
	}
	y->pusht(ld0,ld1,rd0,rd1);
	rt=merge(merge(x,y),z);
}
inline int ask(int l,int r){
	node *x,*y,*z;int res;
	splitl(rt,l,x,y),splitr(y,r,y,z);
	node *pl=findl(y),*pr=findr(y);
	res=sum(y)-(l-pl->l)*pl->v-(pr->r-r)*pr->v;
	rt=merge(merge(x,y),z);
	return res;
}
void del(node* p){
	p->pushdown();
	if(p->l>p->r){
		node *x,*y,*z;
		if(p->l==1)return splitl(rt,1,x,rt);
		if(p->r==n)return splitr(rt,n,rt,x);
		splitl(rt,p->r,x,y),splitr(y,p->l,y,z);
		node *pl=findl(y),*pr=findr(y);
		rt=merge(merge(x,newn(pl->l,pr->r,pl->v)),z); 
		return;
	}
	if(min(ml(p->ls,0),ml(p->ls,1))==0) del(p->ls);
	else if(min(ml(p->rs,0),ml(p->rs,1))==0) del(p->rs);
}

int main()
{
	srand(2333);
	n=read(),m=read();
	int v=-1,lst=-1;
	For(i,1,n){
		a[i]=read();
		if(a[i]!=v){
			if(v>=0)rt=merge(rt,newn(lst,i-1,v));
			v=a[i],lst=i;
		}
	}
	rt=merge(rt,newn(lst,n,v));
//	print(rt),puts("");
	int res=0;
	For(_,1,m)
	{
		int op=read(),l=read()^res,r=read()^res;
		if(op<=2) assign(l,r,op-1);
		else if(op<=6){
			if(op==3) move(l,r, 0,-1,-1, 0,1);
			if(op==4) move(l,r, 1, 0, 0, 1,0);
			if(op==5) move(l,r,-1, 0, 0,-1,0);
			if(op==6) move(l,r, 0, 1, 1, 0,1);
		}else printf("%d\n",res=ask(l,r));
		if(op>=3){
			while(min(ml(rt,0),ml(rt,1))==0) del(rt);
		}
	}
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 30
Accepted

Test #1:

score: 30
Accepted
time: 1ms
memory: 7896kb

input:

1000 1000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 ...

output:

48
40
618
15
96
63
483
101
281
574
215
176
159
676
447
163
193
492
54
175
254
168
73
254
64
57
337
280
3
105
201
299
1
33
93
1
15
2
57
170
47
139
65
245
136
91
24
85
24
6
8
81
100
248
195
272
266
112
32
69
257
54
29
12
193
76
159
30
67
260
38
256
357
161
60
50
0
32
0
167
232
291
201
113
228
85
233
3...

result:

ok 403 lines

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 20
Accepted
time: 9ms
memory: 9208kb

input:

100000 100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

761
571
1734
2014
2109
1110
104
3678
1694
2331
643
312
144
306
3952
997
234
1248
1450
3401
2136
890
288
2570
3664
1514
2104
347
468
1601
2785
1223
2124
1149
475
659
618
856
2255
406
3022
3019
453
1121
2040
714
1462
1739
995
2162
395
2602
2357
665
3636
2995
890
1923
469
1724
1596
2476
79
3107
175
171...

result:

ok 19972 lines

Test #3:

score: 20
Accepted
time: 6ms
memory: 9128kb

input:

100000 100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

70324
41426
25179
2567
34518
12103
27516
5800
14488
25223
14739
53605
16191
34113
76300
37329
4312
33732
28744
35765
27765
55554
26764
16396
63365
5078
15784
20997
12118
22708
43838
59592
71333
12421
8158
48619
14851
2867
25598
30952
63307
19380
39999
62493
7838
21619
1221
60792
62580
20568
31568
33...

result:

ok 19945 lines

Test #4:

score: 20
Accepted
time: 119ms
memory: 11324kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 ...

output:

2637
1783
494
315
2610
2093
2256
903
7524
1584
4679
5313
4144
11667
8582
467
3343
9308
2228
1626
2377
6224
7791
2601
4057
4737
4011
3378
2564
5665
1119
341
2154
801
1446
5977
5441
4180
5277
3023
2181
2717
6266
10146
3768
1509
5447
354
1889
2963
7169
5355
3310
4996
5263
7042
9740
4721
1063
1463
5320
...

result:

ok 13339 lines

Test #5:

score: 20
Accepted
time: 54ms
memory: 13372kb

input:

100000 100000
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

22460
40042
443
10489
19175
3759
19632
18607
23647
11463
26267
21773
5775
32337
7360
3822
3256
46896
22440
3524
19213
12123
10501
5454
18258
3543
15590
10810
35334
725
4776
6667
3997
20208
5190
9729
22601
28741
17120
16562
255
6293
1850
1038
752
9658
1401
1852
14414
4829
1199
3454
4401
5258
8318
155...

result:

ok 40559 lines

Test #6:

score: 20
Accepted
time: 75ms
memory: 23652kb

input:

100000 100000
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ...

output:

2837
7391
191
1110
443
962
244
1310
1857
2697
2040
1163
2221
2863
4113
1396
2195
0
2093
4443
2733
163
1725
2660
5909
2850
488
3214
618
5588
1724
7052
3323
4067
5610
57
7489
2725
8264
3702
447
35
680
6690
7063
9440
5025
12165
9414
8970
9218
7364
5283
6915
6352
3755
8678
3675
4228
3903
3740
2700
10926...

result:

ok 4504 lines

Test #7:

score: 20
Accepted
time: 93ms
memory: 21484kb

input:

100000 100000
1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 1 0 1 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 0 1 0 0 1 0 1 0 1 1 0 1 1 0 1 1 1 1 0 0 1 0 0 0 0 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 ...

output:

40625
26965
7415
728
1470
28211
52372
25125
40433
9935
9464
13760
17
7389
23874
1952
13670
3433
11979
20200
148
5116
3506
25335
1635
6264
5681
15797
2673
19848
890
2110
17958
22270
3929
747
21767
588
16149
1386
2389
1117
12877
9037
12784
5799
9342
11936
11440
17981
17974
5945
7209
12119
1904
5557
98...

result:

ok 22601 lines

Test #8:

score: 20
Accepted
time: 90ms
memory: 21500kb

input:

100000 100000
1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 ...

output:

36664
16431
4675
5431
3715
1101
6950
753
559
578
497
476
907
2632
370
590
45
2329
618
612
1207
493
16
218
237
120
203
602
2361
617
1449
0
210
207
703
770
445
1114
1079
770
397
255
1915
824
0
1125
730
85
1429
1602
1587
1014
1112
338
230
2381
2473
3661
849
1142
811
3033
1521
467
1168
1403
125
3573
390...

result:

ok 22514 lines

Test #9:

score: 20
Accepted
time: 88ms
memory: 11308kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

88
3555
628
587
1088
4648
589
1467
1413
2860
406
1896
2173
1224
1065
2497
2015
1104
612
191
1813
380
185
2365
139
1522
1141
704
3444
4563
2524
4860
591
4043
294
549
212
2254
5285
1433
3362
2197
2246
280
2011
1947
1281
2067
4074
1306
835
3462
508
1514
1408
2198
4691
1448
2966
913
3597
250
2808
1027
2...

result:

ok 9637 lines

Test #10:

score: 20
Accepted
time: 61ms
memory: 11452kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

381
170
164
2187
900
456
3465
480
2080
4399
14
3353
1636
2316
2922
12
1658
1731
267
1588
3269
3272
1988
1269
1601
2371
3703
3416
5489
5292
6644
6470
3549
207
1683
8238
1267
4016
6802
7753
253
1408
5598
3196
1852
1504
3258
12755
2080
4150
10328
4575
8605
4547
3829
4962
13316
6610
11659
12448
10845
46...

result:

ok 3085 lines

Test #11:

score: 20
Accepted
time: 135ms
memory: 15416kb

input:

100000 100000
0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 ...

output:

6419
3723
11634
19067
666
3521
2935
13535
1687
5696
285
15181
7392
229
9695
5662
9729
9505
11545
8409
4619
3213
34080
15049
3233
1162
13223
8003
19083
13504
3825
1082
9727
1328
5331
17890
15565
3829
5330
8504
5270
8601
9964
5764
7261
1544
15393
14264
1398
3863
3878
262
1830
7647
1801
6751
1681
15175...

result:

ok 13144 lines

Test #12:

score: 20
Accepted
time: 88ms
memory: 17472kb

input:

100000 100000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 ...

output:

35020
32413
7760
6897
3408
707
24747
43391
12828
17641
12638
19494
20858
18362
20655
32057
572
500
10704
2191
14630
5885
1042
2893
17259
15248
4783
20468
7373
8433
21168
40089
9187
7094
8613
22280
22474
14513
18766
53712
22914
55272
12112
7846
12149
14245
23190
12539
9130
21879
22681
21245
25774
387...

result:

ok 10038 lines

Test #13:

score: 20
Accepted
time: 126ms
memory: 17432kb

input:

100000 100000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 ...

output:

49045
27318
14832
7536
35455
38648
23398
8175
19521
56516
34068
23768
16998
3333
1528
7914
29600
51592
4839
12642
23708
17248
13593
25872
3391
56018
4845
9701
18938
13752
25445
15741
8207
2783
41639
14394
836
10289
3718
17364
15538
1858
5981
12436
8185
16872
23503
21208
47562
65981
10993
3519
22197
...

result:

ok 50081 lines

Test #14:

score: 20
Accepted
time: 98ms
memory: 15732kb

input:

100000 100000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 ...

output:

47139
4127
4174
8521
4929
8921
13590
32548
11617
16988
24981
41393
7519
12990
12478
18069
12917
13223
39713
15958
18554
36091
56971
49204
10131
18920
8739
4051
4030
20129
2488
2236
12580
44006
7965
5299
3545
1242
6971
4569
38508
18869
26225
3250
19512
17378
25024
23487
7837
2044
4580
12658
4119
3360...

result:

ok 80099 lines

Test #15:

score: 20
Accepted
time: 95ms
memory: 11744kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 ...

output:

3293
10527
2367
329
587
6547
173
7754
3832
645
1483
7128
1044
2224
5292
48
3895
2980
579
3482
4120
825
324
7376
2693
9475
3904
1210
6647
20388
11230
601
7199
3933
2247
332
5246
21844
13840
4546
30790
18412
10161
28668
2366
6474
2582
6203
11949
14505
8640
36055
42165
18215
4620
1872
4972
75
1586
3805...

result:

ok 53374 lines

Test #16:

score: 20
Accepted
time: 69ms
memory: 8628kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0
1861
2420
669
320
185
339
1340
676
2481
945
478
9434
5805
1701
4985
6686
722
12022
22138
19384
39783
4435
45373
39578
48150
32092
467
18876
337
13640
476
11887
12487
4480
6670
4224
804
109
279
1143
1986
961
266
210
2883
345
6117
5923
903
675
12981
4834
7524
6936
12
481
989
4648
3801
823
906
2932
8...

result:

ok 33609 lines

Test #17:

score: 20
Accepted
time: 81ms
memory: 15348kb

input:

100000 100000
0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ...

output:

14491
3432
5696
26456
2237
23273
12298
13521
4534
9991
6543
5590
2777
21709
4335
3472
2385
3629
8078
2193
20790
4618
1077
4421
896
22391
4016
922
6727
327
2827
23040
4970
1402
4480
11207
7559
12381
9947
9276
11481
13907
12213
6163
9901
5480
2573
11340
4014
9045
10349
10854
11280
29740
46
5254
5656
8...

result:

ok 14897 lines

Test #18:

score: 20
Accepted
time: 58ms
memory: 11436kb

input:

100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

98
1754
1221
346
999
2285
143
892
4446
4656
6181
4687
183
3196
7608
124
230
2313
9316
9483
93
9104
281
95
3505
12700
175
13193
7928
14703
93
9357
117
200
346
233
9
13241
13046
12403
4099
13
10956
3693
9490
138
114
835
4182
203
1010
218
15
192
3539
156
1625
376
1355
784
635
24
3723
3365
4991
2623
512...

result:

ok 29044 lines

Test #19:

score: 20
Accepted
time: 8ms
memory: 9208kb

input:

100000 100000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

24096
32278
42035
36407
30343
17436
22040
17280
47582
54804
30266
55662
50336
39226
3511
49798
6854
73825
29306
12421
14681
27530
26984
29217
57916
21345
15894
59759
13167
8239
1675
1733
59514
93
57526
86232
26752
6524
63567
36077
62197
55446
5338
50071
9782
35147
37347
71825
4625
53185
44453
50172
...

result:

ok 19814 lines

Subtask #3:

score: 30
Accepted

Test #20:

score: 30
Accepted
time: 521ms
memory: 89576kb

input:

1000000 1000000
1 1 0 0 0 1 1 1 0 1 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 ...

output:

158940
196286
65713
368478
44549
30782
5953
312656
61134
0
25449
0
0
10885
0
41259
0
563050
295965
134732
0
606641
230542
150324
145284
144324
118883
0
178503
24252
159072
95898
230327
254751
44922
106576
0
0
0
114071
0
166294
69310
71608
8
221987
230654
3733
0
0
172518
17191
226832
219720
333976
57...

result:

ok 142590 lines

Subtask #4:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #21:

score: 10
Accepted
time: 2211ms
memory: 77288kb

input:

1000000 1000000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 ...

output:

315082
10545
281550
276564
232040
274203
232077
123641
207265
363209
82527
461952
132659
73228
169073
149572
189271
174913
100195
8079
103904
271862
89759
59493
128618
22669
116127
76893
8840
19767
79633
220884
378654
405382
324409
89779
435149
67205
80256
275878
58974
185334
214292
49441
248879
204...

result:

ok 899896 lines

Test #22:

score: 10
Accepted
time: 912ms
memory: 75268kb

input:

1000000 1000000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 ...

output:

366444
3241
84921
73525
465969
248480
170286
208036
254773
48425
136386
72817
61491
134367
271857
571191
171497
95456
56631
11290
292927
1663
108785
103707
151692
124224
183754
198190
311524
228962
97110
174646
210216
39530
5292
131512
24378
131079
393092
650843
247497
196512
192615
112509
201738
23...

result:

ok 99231 lines

Test #23:

score: 10
Accepted
time: 649ms
memory: 13632kb

input:

1000000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

1159
1061
6020
9030
15050
18060
24080
33110
39130
42140
51170
54180
57190
60200
69230
84280
90300
93310
111370
123410
135449
156510
150490
147480
141460
126410
117380
111360
105340
102330
87280
81260
78250
72230
54170
39120
27081
24072
12036
536
6447
7987
6389
3194
12942
33074
35950
38826
40264
4170...

result:

ok 233962 lines

Test #24:

score: 10
Accepted
time: 482ms
memory: 20016kb

input:

1000000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

23495
8604
155096
174483
310191
135717
38787
19401
4400
42458
339665
318437
275981
212297
191069
169841
63701
3123
81276
142221
162536
264111
284426
365682
426624
528194
507881
487568
426629
386003
223499
162560
101621
81887
95530
136459
150102
136456
122812
109169
68240
40954
55819
183957
209584
23...

result:

ok 238549 lines

Test #25:

score: 10
Accepted
time: 876ms
memory: 50660kb

input:

1000000 1000000
0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 ...

output:

55826
93666
73265
36679
222451
444899
111225
58482
87723
58482
38304
100683
50388
67594
87781
6563
63136
96019
243518
364692
244075
82122
83418
41268
20675
272155
217836
163517
109199
21320
159117
207805
131747
260909
131751
225560
114150
77675
39170
9852
49169
113929
151282
188635
114481
77404
349
...

result:

ok 286431 lines

Test #26:

score: 10
Accepted
time: 788ms
memory: 13804kb

input:

1000000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

420
1239
22875
42795
446
4096
39952
82066
287
9383
2617
105580
22321
56529
1167
114638
86517
117014
109799
20353
22686
1015
55217
2253
61977
11081
10889
43169
29073
427
97
2324
7045
1107
3778
24989
14221
24596
169
43859
35444
45770
2315
6352
56559
6927
4415
19245
65928
146
7469
1255
89
1363
575
7360...

result:

ok 288782 lines

Test #27:

score: 10
Accepted
time: 1796ms
memory: 30188kb

input:

1000000 1000000
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 ...

output:

43459
61754
82079
62430
326
57468
65150
83422
6604
126304
12160
23894
31952
44211
1236
71948
23582
4608
42098
22276
52794
69531
11320
21935
34096
16761
9357
84298
32193
16375
78854
11981
431
8783
58371
9084
50092
39770
37086
20406
55567
2706
50256
70895
47056
43601
41707
8003
9706
1334
60315
22747
4...

result:

ok 128466 lines

Subtask #5:

score: 10
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #28:

score: 10
Accepted
time: 1588ms
memory: 249332kb

input:

3000000 3000000
1 1 0 0 0 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 ...

output:

477148
588684
197261
1105353
133667
92857
17947
936942
182543
0
76345
0
0
32656
0
123781
0
1689155
887900
404201
0
1819871
691627
450972
435838
432969
356647
0
535510
72756
477214
287698
690983
764230
134768
319727
0
0
0
342210
0
498884
207933
214825
24
665961
691962
11317
0
0
517556
51576
680499
65...

result:

ok 427770 lines

Test #29:

score: 10
Accepted
time: 1645ms
memory: 249324kb

input:

3000000 3000000
1 1 0 0 0 1 1 1 0 1 1 0 1 1 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 1 1 1 0 1 1 0 1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 0 0 1 ...

output:

477170
588721
197095
1105131
133588
92762
17933
937214
182636
0
76348
0
0
32655
0
123780
0
1689156
887906
404201
0
1819880
691626
450970
435827
432970
356647
0
535509
72757
477214
287696
690982
764270
134769
319728
0
0
0
342210
0
498886
207934
214825
25
665959
691961
11367
0
0
517553
51577
680499
65...

result:

ok 427770 lines

Test #30:

score: 10
Accepted
time: 3510ms
memory: 208360kb

input:

3000000 3000000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 ...

output:

945250
31635
844653
829696
696123
822610
696235
370926
621795
1089631
247585
1385859
397981
219683
507221
448719
567817
524741
300589
24238
311712
815588
269279
178482
385856
68011
348383
230680
26520
59303
238900
662655
1135964
1216150
973231
269339
1305450
201619
240769
827639
176926
556006
642877...

result:

ok 2699688 lines

Test #31:

score: 10
Accepted
time: 5752ms
memory: 71208kb

input:

3000000 3000000
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 ...

output:

130378
185266
246237
187291
980
172404
195451
250266
19812
378915
36480
71683
95857
132632
3708
215843
70746
13823
126293
66826
158385
208590
33963
65802
102287
50277
28074
252889
96576
49128
236564
35947
1292
26354
175113
27253
150280
119303
111256
61221
166685
8116
150764
212681
141160
130791
1251...

result:

ok 385398 lines

Test #32:

score: 10
Accepted
time: 1679ms
memory: 206432kb

input:

3000000 3000000
1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 ...

output:

1978780
1964099
986219
998776
1976639
1978058
998150
1962084
1960901
1975190
986091
982035
993805
1970905
1962235
1974957
1964311
1958777
982034
1977014
989618
999053
992438
1958533
981971
997798
1966877
991033
1962033
981970
981970
1964998
1964867
1974222
981973
981331
1977751
984497
1962031
197246...

result:

ok 297693 lines