QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#953416#7487. 不归之人与望眼欲穿的人们sunkaihuanAC ✓944ms61356kbC++143.1kb2025-03-27 19:36:372025-03-27 19:36:37

Judging History

This is the latest submission verdict.

  • [2025-03-27 19:36:37]
  • Judged
  • Verdict: AC
  • Time: 944ms
  • Memory: 61356kb
  • [2025-03-27 19:36:37]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e4+5,L=31;
#define M 131131
#define fi first
#define se second
int n,m,d,a[N],mx[M],id[M];
set<unsigned short> s[L];
pair<unsigned short,int> l[L+5],r[L+5],tl[L+5];
priority_queue<int> w[N],de[N];
int c[L+5][L+5],lc,rc;

void build(int p,int l,int r){
	if(l==r){id[l]=p;return;}int mid=(l+r)>>1;
	build(p*2,l,mid),build(p*2+1,mid+1,r);
}

void ins(int x,int v){//cerr<<"ins: "<<x<<" "<<v<<"\n";
	w[x].push(v);
	while(de[x].size()&&w[x].top()==de[x].top())
		w[x].pop(),de[x].pop();
	mx[id[x]]=(w[x].size()?w[x].top():0);x=id[x];
	while(x>1)mx[x>>1]=max(mx[x],mx[x^1]),x>>=1;
}

void del(int x,int v){//cerr<<"del: "<<x<<" "<<v<<"\n";
	de[x].push(v);
	while(de[x].size()&&w[x].top()==de[x].top())
		w[x].pop(),de[x].pop();
	mx[id[x]]=(w[x].size()?w[x].top():0);x=id[x];
	while(x>1)mx[x>>1]=max(mx[x],mx[x^1]),x>>=1;
}

int ask(int v){
	int x=1,l=1,r=n,md;
	while(l<r){
		md=(l+r)>>1;
		if(mx[x*2]>=v)x=x*2,r=md;
		else x=x*2+1,l=md+1;
	}return mx[x]>=v?l:l+1;
}

void get(int x){
	for(int i=0;i<L;i++){
		auto it=s[i].upper_bound(x-1);
		l[i]={it==s[i].begin()?0:*(--it),1<<i};
		it=s[i].lower_bound(x+1);
		r[i]={it==s[i].end()?65535:*it,1<<i};
	}sort(l,l+L);reverse(l,l+L);sort(r,r+L);
	lc=rc=0;tl[0]={x,0};
	for(int i=0;i<L;i++){
		if(l[i].fi==0)break;
		if((!lc)||tl[lc].fi!=l[i].fi)
			tl[lc+1]={l[i].fi,tl[lc].se},lc++;
		tl[lc].se|=l[i].se;
	}memcpy(l,tl,sizeof(l));
	for(int i=0;i<L;i++){
		if(r[i].fi==65535)break;
		if((!rc)||tl[rc].fi!=r[i].fi)
			tl[rc+1]={r[i].fi,tl[rc].se},rc++;
		tl[rc].se|=r[i].se;
	}memcpy(r,tl,sizeof(r));
	// cerr<<x<<" "<<lc<<" "<<rc<<"\n";
}

void add(int x){
	for(int i=0;i<=lc;i++)
		for(int j=0;j<=rc;j++)
			c[i][j]=l[i].se|r[j].se|a[x];
	for(int i=1;i<=lc;i++)
		for(int j=1;j<=rc;j++){
			if(c[i][j]>c[i-1][j]&&c[i][j]>c[i][j-1])
				ins(r[j].fi-l[i].fi+1,c[i][j]);
		}
	for(int i=1;i<=lc;i++)
		if((l[i].se|a[x])>(l[i-1].se|a[x])&&(l[i].se|a[x])>l[i].se)
			ins(x-l[i].fi+1,l[i].se|a[x]);
	for(int i=1;i<=rc;i++)
		if((r[i].se|a[x])>(r[i-1].se|a[x])&&(r[i].se|a[x])>r[i].se)
			ins(r[i].fi-x+1,r[i].se|a[x]);
	ins(1,a[x]);
	for(int i=0;i<L;i++)
		if((a[x]>>i)&1)s[i].insert(x);
}

void clr(int x){
	for(int i=0;i<=lc;i++)
		for(int j=0;j<=rc;j++)
			c[i][j]=l[i].se|r[j].se|a[x];
	for(int i=1;i<=lc;i++)
		for(int j=1;j<=rc;j++){
			if(c[i][j]>c[i-1][j]&&c[i][j]>c[i][j-1])
				del(r[j].fi-l[i].fi+1,c[i][j]);
		}
	for(int i=1;i<=lc;i++)
		if((l[i].se|a[x])>(l[i-1].se|a[x])&&(l[i].se|a[x])>l[i].se)
			del(x-l[i].fi+1,l[i].se|a[x]);
	for(int i=1;i<=rc;i++)
		if((r[i].se|a[x])>(r[i-1].se|a[x])&&(r[i].se|a[x])>r[i].se)
			del(r[i].fi-x+1,r[i].se|a[x]);
	del(1,a[x]);
	for(int i=0;i<L;i++)
		if((a[x]>>i)&1)s[i].erase(x);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n>>m; int op,x,y; build(1,1,n);
	for(int i=1;i<=n;i++)cin>>a[i],get(i),add(i);//print();
	for(int i=1;i<=m;i++){
		cin>>op>>x;
		if(op==1)cin>>y,get(x),clr(x),a[x]=y,add(x);
		else cout<<((y=ask(x))>n?-1:y)<<"\n";//print();
	}return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 85ms
memory: 13440kb

input:

50000 50000
2 4 268435456 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8...

output:

49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
-1
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
49990
499...

result:

ok 49513 lines

Test #2:

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

input:

100 100
9 7 708965945 8 2 354292040 930825555 9 118129428 788436306 305559230 367145168 4 299894270 375348388 8 547824309 676446459 2 218072794 549910922 807447019 6 2 302567598 9 6 2 551833177 3 633435229 7 666781617 265451551 49989127 5 112752191 380659534 8 957857679 5 197069264 5 152574163 10 82...

output:

5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
-1
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5

result:

ok 91 lines

Test #3:

score: 0
Accepted
time: 3ms
memory: 6984kb

input:

1000 1000
15 18 18 19 16 12 18 19 9 11 10 11 5 12 4 6 5 5 8 13 7 8 6 5 9 4 6 10 4 12 8 4 8 9 7 530372552 6 13 8 4 12 13 9 5 4 12 8 7 6 12 6 5 5 12 7 13 13 4 1 5 10 9 9 3 8 3 10 5 7 8 9 10 7 8 6 6 2 7 4 6 7 5 1 10 2 8 4 3 5 1 1 15849904 10 10 7 3 17 16 798931520 14 15 13 9 13 16 15 13 10 9 10 10 17 1...

output:

14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
-1
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
14
...

result:

ok 889 lines

Test #4:

score: 0
Accepted
time: 9ms
memory: 7504kb

input:

5000 5000
2 268435456 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 1...

output:

4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
4999
...

result:

ok 4954 lines

Test #5:

score: 0
Accepted
time: 8ms
memory: 7504kb

input:

5000 5000
2 4 8 16 32 64 128 256 268435456 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 ...

output:

4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
-1
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
4986
49...

result:

ok 4941 lines

Test #6:

score: 0
Accepted
time: 72ms
memory: 15048kb

input:

10000 10000
107288584 481475733 756273809 244598825 402029138 341300101 437916799 570513418 384481063 579359934 722185275 606537803 835222680 228305693 973147907 262319251 636389316 485937670 291443057 325541254 822755077 172256419 627275005 481514021 757253871 311471253 18917510 457661976 431794148...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 8992 lines

Test #7:

score: 0
Accepted
time: 94ms
memory: 15808kb

input:

10000 10000
2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8...

output:

2
2
2
3
2
2
4
5
2
5
2
6
3
6
2
4
5
4
3
3
2
3
2
2
4
3
2
2
6
3
5
4
2
3
2
2
3
2
2
5
3
3
2
3
3
4
3
2
7
5
4
2
2
8
2
3
4
2
2
2
4
4
5
2
5
4
3
3
5
5
2
6
2
2
4
2
5
4
4
2
6
4
3
2
2
2
2
5
3
3
4
2
3
5
2
2
2
3
2
3
4
2
6
2
2
3
3
2
2
2
2
2
4
2
2
8
5
2
2
3
3
2
3
2
2
3
2
4
3
3
3
3
2
2
3
5
3
2
3
3
3
2
2
2
3
2
3
4
6
2
...

result:

ok 7558 lines

Test #8:

score: 0
Accepted
time: 80ms
memory: 12240kb

input:

50000 50000
2 4 8 16 32 64 268435456 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 1...

output:

49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
49994
...

result:

ok 50000 lines

Test #9:

score: 0
Accepted
time: 81ms
memory: 12484kb

input:

50000 50000
2 4 8 16 32 64 128 256 512 268435456 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16...

output:

49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
49987
...

result:

ok 50000 lines

Test #10:

score: 0
Accepted
time: 85ms
memory: 13004kb

input:

50000 50000
2 4 268435456 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8...

output:

49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
49998
...

result:

ok 49466 lines

Test #11:

score: 0
Accepted
time: 2ms
memory: 7624kb

input:

1000 1000
2 4 8 16 32 64 268435456 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 ...

output:

988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
988
...

result:

ok 997 lines

Test #12:

score: 0
Accepted
time: 85ms
memory: 13504kb

input:

50000 50000
2 4 8 16 32 64 128 256 268435456 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 1...

output:

49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
-1
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
49985
499...

result:

ok 49515 lines

Test #13:

score: 0
Accepted
time: 944ms
memory: 61356kb

input:

50000 50000
2 4 8 268435456 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 ...

output:

49996
49996
49996
49996
49996
49996
49996
49996
22850
49996
49996
49996
49996
49996
46106
22850
49996
9397
19122
39441
3729
39441
19122
22374
13454
12295
19122
1135
1135
1135
1135
1135
1135
1135
1135
-1
1135
1135
1135
1135
1135
1135
1135
1135
1135
1135
1135
722
722
722
722
722
722
722
722
722
722
72...

result:

ok 498 lines

Test #14:

score: 0
Accepted
time: 12ms
memory: 7752kb

input:

5000 5000
10 5 11 10 11 8 5 8 12 12 17 9 16 14 14 17 565544862 14 15 18 12 12 18 11 16 16 15 13 9 9 17 11 17 16 11 12 12 11 11 14 11 11 13 15 12 17 11 12 11 13 14 14 7 14 9 8 11 9 13 11 6 13 7 9 5 7 14 8 7 10 2 9 5 6 1 4 5 5 3 5 7 6 5 4 6 16 14 18 9 17 10 14 11 15 13 5 13 12 6 5 12 12 4 5 4 9 7 12 7...

output:

26
26
26
26
26
26
26
26
26
26
26
26
26
-1
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
26
-1
26
26
26
26
26
26
26
26
26
...

result:

ok 4542 lines

Test #15:

score: 0
Accepted
time: 31ms
memory: 10448kb

input:

5000 5000
825843123 786553404 384872066 905962623 918299177 811610737 800504945 435889328 494814955 590973425 84628817 996578491 774766607 44191752 20168785 204250070 437544467 481439559 156707198 825687793 767254178 904359511 517633282 141578693 922040155 432080022 432067697 434566554 328794339 851...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

result:

ok 4523 lines

Test #16:

score: 0
Accepted
time: 15ms
memory: 8652kb

input:

10000 10000
2 4 8 16 32 64 268435456 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 1...

output:

9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
-1
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
9993
99...

result:

ok 9906 lines

Test #17:

score: 0
Accepted
time: 14ms
memory: 8408kb

input:

10000 10000
2 4 8 16 32 64 128 256 512 268435456 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16...

output:

9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
9984
...

result:

ok 9912 lines

Test #18:

score: 0
Accepted
time: 402ms
memory: 42320kb

input:

50000 50000
250187767 745413531 153888052 25958606 294904524 440512794 747593687 737012723 955752867 316732060 195090839 646677357 537788732 190247043 475295336 261145693 855119520 707605600 289015082 832914823 687618838 458632399 78418484 536398309 363240163 215054569 171430402 768863008 464922321 ...

output:

2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 lines

Test #19:

score: 0
Accepted
time: 392ms
memory: 43336kb

input:

50000 50000
794776667 230781065 932994210 103198689 916371777 428637699 724975533 37305805 909586094 597589147 892837465 578568691 882116424 714596387 299748497 127861615 137171620 765565048 139050902 307844120 223974523 202334813 47470576 982520990 113893328 524779458 343620612 401790787 501073229 ...

output:

2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
-1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 50000 lines

Test #20:

score: 0
Accepted
time: 84ms
memory: 13256kb

input:

50000 50000
2 4 8 16 32 64 268435456 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 1 2 4 8 1...

output:

49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
49989
...

result:

ok 49506 lines