QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178929#3097. Shoppingsjc061031#10 5ms4024kbC++203.7kb2023-09-14 15:41:302024-07-04 01:59:22

Judging History

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

  • [2024-07-04 01:59:22]
  • 评测
  • 测评结果:10
  • 用时:5ms
  • 内存:4024kb
  • [2023-09-14 15:41:30]
  • 提交

Anna

#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;

namespace{
	int n,l,r,all,a[10010],d[100010];
}

void InitA(int N,int L,int R){
	n=N;
	l=L;
	r=R;
	if(n<=10000){
		int posl=l/100;
		int posr=r/100;
		for(int i=0;i<9;i++){
			if(posl&(1<<i)) SendA(1);
			else SendA(0); 
		}
		for(int i=0;i<9;i++){
			if(posr&(1<<i)) SendA(1);
			else SendA(0);
		}
	}
	else{
		int posl=l/200;
		int posr=r/200;
		for(int i=0;i<9;i++){
			if(posl&(1<<i)) SendA(1);
			else SendA(0);
		}
		for(int i=0;i<9;i++){
			if(posr&(1<<i)) SendA(1);
			else SendA(0);
		}
	}
}

void ReceiveA(bool x){
	all++;
	a[all]=x;
}

int Answer(){
	if(n<=10000){
		int posl=l/100,posr=r/100,tot=0,minv=n+1,pos=-1;
		for(int i=posl;i<=posr;i++){
			int L=i*100,R=min((i+1)*100-1,n);
			if(i==posl||i==posr){
				for(int j=L;j<=R;j++){
					d[j]=0;
					for(int k=0;k<20;k++){
						tot++;
						if(a[tot]) d[j]+=(1<<k);
					}
				}
				for(int j=max(l,L);j<=min(r,R);j++){
					if(d[j]<minv){
						minv=d[j];pos=j;
					}
				}
			}
			else{
				int loc=0;
				for(int k=0;k<20;k++){
					tot++;
					if(a[tot]) loc+=(1<<k);
				}
				int cur=0;
				for(int k=0;k<20;k++){
					tot++;
					if(a[tot]) cur+=(1<<k);
				}
				if(cur<minv){
					minv=cur;pos=loc;
				}
			}
		}
		return pos;
	}
	else{
		int posl=l/200,posr=r/200,tot=0,minv=n+1,pos=-1;
		bool flag=false;
		for(int i=posl;i<=posr;i++){
			int L=i*200,R=min((i+1)*200-1,n);
			if(i==posl||i==posr){
				for(int j=L;j<=R;j++){
					d[j]=0;
					for(int k=0;k<17;k++){
						tot++;
						if(a[tot]) d[j]+=(1<<k);
					}
				}
				for(int j=max(l,L);j<=min(r,R);j++){
					if(d[j]<minv){
						minv=d[j];pos=j;
					}
				}
			}
			else{
				flag=true;
			}
		}
		if(flag){
			int loc=0;
			for(int j=0;j<17;j++){
				tot++;
				if(a[tot]) loc+=(1<<j);
			}
			int cur=0;
			for(int j=0;j<17;j++){
				tot++;
				if(a[tot]) cur+=(1<<j);
			}
			if(cur<minv){
				minv=cur;pos=loc;
			}
		}
		return pos;
	}
}

Bruno

#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;

namespace{
	int m,cnt,b[20],c[100010];
}

void InitB(int N,vector<int> P){
	m=N;
	for(int i=0;i<m;i++) c[i]=P[i];
}

void ReceiveB(bool y){
	if(m<=10000){
		cnt++;b[cnt]=y;
		if(cnt==18){
			int posl=0,posr=0;
			for(int i=1;i<=9;i++) posl+=(1<<(i-1))*b[i];
			for(int i=10;i<=18;i++) posr+=(1<<(i-10))*b[i];
			for(int i=posl;i<=posr;i++){
				int L=i*100,R=min((i+1)*100-1,m);
				if(i==posl||i==posr){
					for(int j=L;j<=R;j++){
						for(int k=0;k<20;k++){
							if(c[j]&(1<<k)) SendB(1);
							else SendB(0);
						}
					}
				}
				else{
					int minv=m+1,pos=-1;
					for(int j=L;j<=R;j++) if(c[j]<minv){
						minv=c[j];pos=j;
					}
					for(int k=0;k<20;k++){
						if(pos&(1<<k)) SendB(1);
						else SendB(0);
					}
					for(int k=0;k<20;k++){
						if(c[pos]&(1<<k)) SendB(1);
						else SendB(0);
					}
				}
			}
		}
	}
	else{
		cnt++;b[cnt]=y;
		if(cnt==18){
			int posl=0,posr=0;
			for(int i=1;i<=9;i++) posl+=(1<<(i-1))*b[i];
			for(int i=10;i<=18;i++) posr+=(1<<(i-10))*b[i];
			int minv=m+1,pos=-1;
			for(int i=posl;i<=posr;i++){
				int L=i*200,R=min((i+1)*200-1,m);
				if(i==posl||i==posr){
					for(int j=L;j<=R;j++){
						for(int k=0;k<17;k++){
							if(c[j]&(1<<k)) SendB(1);
							else SendB(0);
						}
					}
				}
				else{
					for(int j=L;j<=R;j++) if(c[j]<minv){
						minv=c[j];pos=j;
					}
				}
			}
			if(pos!=-1){
				for(int j=0;j<17;j++){
					if(pos&(1<<j)) SendB(1);
					else SendB(0);
				}
				for(int j=0;j<17;j++){
					if(c[pos]&(1<<j)) SendB(1);
					else SendB(0);
				}
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 1ms
memory: 3660kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-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
-1
-1

input:


output:

Accepted: 18 40

result:

ok 

Test #2:

score: 1
Accepted
time: 1ms
memory: 3880kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
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
-1
-1

input:


output:

Accepted: 18 60

result:

ok 

Test #3:

score: 1
Accepted
time: 0ms
memory: 3852kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
1
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
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
-1
-1

input:


output:

Accepted: 18 80

result:

ok 

Test #4:

score: 1
Accepted
time: 1ms
memory: 3592kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
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
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
-1
-1

input:


output:

Accepted: 18 100

result:

ok 

Test #5:

score: 1
Accepted
time: 1ms
memory: 3848kb

input:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
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
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
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
-1
-1

input:


output:

Accepted: 18 120

result:

ok 

Test #6:

score: 1
Accepted
time: 3ms
memory: 3668kb

input:

0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
1
1
0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
1
1...

input:


output:

Accepted: 18 4160

result:

ok 

Test #7:

score: 1
Accepted
time: 0ms
memory: 3860kb

input:

0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0...

input:


output:

Accepted: 18 4040

result:

ok 

Test #8:

score: 1
Accepted
time: 3ms
memory: 3668kb

input:

1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
0
0
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
0...

input:


output:

Accepted: 18 4000

result:

ok 

Test #9:

score: 1
Accepted
time: 0ms
memory: 3904kb

input:

0
0
0
1
0
0
0
0
0
1
0
0
1
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1...

input:


output:

Accepted: 18 4000

result:

ok 

Test #10:

score: 1
Accepted
time: 0ms
memory: 3656kb

input:

1
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
1
0
0
0
1
0
1
0
1
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
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0...

input:


output:

Accepted: 18 2000

result:

ok 

Test #11:

score: 1
Accepted
time: 3ms
memory: 3652kb

input:

0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
1
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
1
1...

input:


output:

Accepted: 18 4320

result:

ok 

Test #12:

score: 1
Accepted
time: 2ms
memory: 3608kb

input:

1
0
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
0
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1...

input:


output:

Accepted: 18 4040

result:

ok 

Test #13:

score: 1
Accepted
time: 3ms
memory: 3676kb

input:

0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
0
0
1
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0...

input:


output:

Accepted: 18 4040

result:

ok 

Test #14:

score: 1
Accepted
time: 0ms
memory: 3672kb

input:

1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
1
1
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
1
0
0...

input:


output:

Accepted: 18 4000

result:

ok 

Test #15:

score: 1
Accepted
time: 3ms
memory: 3664kb

input:

0
0
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0...

input:


output:

Accepted: 18 4160

result:

ok 

Test #16:

score: 1
Accepted
time: 2ms
memory: 3676kb

input:

1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1...

input:


output:

Accepted: 18 4080

result:

ok 

Test #17:

score: 1
Accepted
time: 0ms
memory: 3904kb

input:

0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
0
0
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
1
1...

input:


output:

Accepted: 18 4000

result:

ok 

Test #18:

score: 1
Accepted
time: 0ms
memory: 3896kb

input:

1
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
1
0
1...

input:


output:

Accepted: 18 2000

result:

ok 

Test #19:

score: 1
Accepted
time: 2ms
memory: 3672kb

input:

1
0
1
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
-1
-1
-1

output:

-1
1
1
1
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
1
1
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
1
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
1...

input:


output:

Accepted: 18 2000

result:

ok 

Test #20:

score: 1
Accepted
time: 1ms
memory: 3668kb

input:

1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
-1
-1
-1

output:

-1
0
0
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
1
1
1...

input:


output:

Accepted: 18 2000

result:

ok 

Subtask #2:

score: 9
Accepted

Test #21:

score: 9
Accepted
time: 5ms
memory: 4024kb

input:

1
0
0
0
0
1
0
0
0
1
1
0
0
1
0
1
0
0
-1
-1
-1

output:

-1
1
1
1
1
1
0
1
1
1
0
1
0
0
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0...

input:


output:

Accepted: 18 5960

result:

ok 

Test #22:

score: 9
Accepted
time: 4ms
memory: 3720kb

input:

0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
-1
-1
-1

output:

-1
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
1
1
0
0
0
0
0
0
0
1
1
1
0
1
1
1
1
0
0
0
1
1
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
0
0...

input:


output:

Accepted: 18 4640

result:

ok 

Test #23:

score: 9
Accepted
time: 4ms
memory: 3764kb

input:

0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
0
-1
-1
-1

output:

-1
1
1
1
0
1
1
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
1
1
1
0
1
1
1
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
1...

input:


output:

Accepted: 18 5200

result:

ok 

Test #24:

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

input:

0
0
0
1
1
1
0
0
0
0
1
1
0
1
0
1
0
0
-1
-1
-1

output:

-1
1
0
1
0
0
1
1
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
0
1
0
0
1
0
0
0
0
0
0
1
1
0
1
1
1
0
0
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
1
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0...

input:


output:

Accepted: 18 5160

result:

ok 

Test #25:

score: 9
Accepted
time: 3ms
memory: 3956kb

input:

0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
-1
-1
-1

output:

-1
0
1
0
1
1
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
1
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
1
0
0
1
0
0
0
0
0
0
1
0
1
1
0
1
1
0
1
0
0
1
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
1
1
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
0...

input:


output:

Accepted: 18 2000

result:

ok 

Test #26:

score: 9
Accepted
time: 1ms
memory: 3752kb

input:

0
0
0
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
-1
-1
-1

output:

-1
0
1
1
1
1
1
1
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
1
0
0
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
0
1
0
1
1
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
1
1
0
0
1
1
0
1
0
1
1
0
0
0
0
0
0
0
1
1
0
1
1
1
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
1
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
0
0
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
1...

input:


output:

Accepted: 18 7920

result:

ok 

Test #27:

score: 9
Accepted
time: 3ms
memory: 3712kb

input:

0
0
1
0
0
0
1
0
0
0
0
0
0
1
0
1
0
0
-1
-1
-1

output:

-1
1
0
0
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
0
1
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
1
1
1
0
1
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0...

input:


output:

Accepted: 18 4440

result:

ok 

Test #28:

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

input:

1
1
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
-1
-1
-1

output:

-1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
0
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
1
1
1
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
0
1
1
1
1
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
0
1
1
1
1
0
1
0...

input:


output:

Accepted: 18 6320

result:

ok 

Test #29:

score: 9
Accepted
time: 4ms
memory: 4000kb

input:

1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
-1
-1
-1

output:

-1
0
1
0
1
1
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
0
1
0
1
0
1
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
1
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
1
0
0...

input:


output:

Accepted: 18 6640

result:

ok 

Test #30:

score: 9
Accepted
time: 3ms
memory: 3700kb

input:

1
1
0
1
1
0
0
0
0
0
1
1
1
1
0
0
0
0
-1
-1
-1

output:

-1
1
0
1
1
1
0
1
0
1
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
1
0
1
1
0
0
0
0
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
0
1
0
0
0
0
0
0
0
1
1
1
0
0
1
0
1
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
1...

input:


output:

Accepted: 18 4080

result:

ok 

Test #31:

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

input:

1
0
1
1
1
1
0
0
0
1
1
0
0
1
0
1
0
0
-1
-1
-1

output:

-1
1
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
0
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
1
1
1
0
0
1...

input:


output:

Accepted: 18 4840

result:

ok 

Test #32:

score: 9
Accepted
time: 1ms
memory: 3752kb

input:

1
1
1
1
0
0
0
0
0
1
0
1
1
1
0
0
0
0
-1
-1
-1

output:

-1
1
0
1
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
1
1
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
1
0
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
1
1
0
0
1...

input:


output:

Accepted: 18 4520

result:

ok 

Test #33:

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

input:

1
1
0
0
1
1
0
0
0
1
0
0
0
0
0
1
0
0
-1
-1
-1

output:

-1
1
1
1
0
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
1
1
1
1
0
0
0
0
0
0
0
0
1
1
0
0
1
0
0
0...

input:


output:

Accepted: 18 4520

result:

ok 

Test #34:

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

input:

0
0
1
1
1
0
0
0
0
1
0
1
1
1
0
0
0
0
-1
-1
-1

output:

-1
1
1
1
0
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
0
0
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
0
1
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1...

input:


output:

Accepted: 18 4000

result:

ok 

Test #35:

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

input:

1
0
1
1
1
0
1
0
0
0
1
1
1
1
0
1
0
0
-1
-1
-1

output:

-1
0
0
1
0
1
1
0
0
1
0
0
1
1
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
1
0
1
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
1
0
1
0
0
0
0
0
0
0
1
1
1
0
0
1
1
0
0...

input:


output:

Accepted: 18 4000

result:

ok 

Test #36:

score: 9
Accepted
time: 2ms
memory: 3956kb

input:

1
1
0
0
1
0
1
0
0
1
1
0
0
1
0
1
0
0
-1
-1
-1

output:

-1
0
1
1
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
1
0
0
1
0
0
0
0
0
0
0
1
1
0
0
0
1
1
1
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
1
1
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
0
1
0
1
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1...

input:


output:

Accepted: 18 2000

result:

ok 

Test #37:

score: 9
Accepted
time: 2ms
memory: 3768kb

input:

0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
-1
-1
-1

output:

-1
1
1
1
0
1
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
1
1
1
1
0
0
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
1
1
0
1
0
0
1
0
1
1
0
0
1
0
0
0
0
0
0
1
1
1
0
0
1
0
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
1
1
1
0
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
1
1
1
1
1
0
0
0
0
1
0
0
0
0
0
0
1
0
1
0
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
0
1
1
1
0
0
1
0...

input:


output:

Accepted: 18 2000

result:

ok 

Subtask #3:

score: 0
Runtime Error

Test #38:

score: 0
Runtime Error

input:


output:


input:


output:


result:

wrong output format Unexpected end of file - token expected