QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#178940#3097. Shoppingsjc061031#10 5ms4004kbC++202.0kb2023-09-14 15:45:202024-07-04 01:59:31

Judging History

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

  • [2024-07-04 01:59:31]
  • 评测
  • 测评结果:10
  • 用时:5ms
  • 内存:4004kb
  • [2023-09-14 15:45:20]
  • 提交

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;
	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(){
	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){
	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);
			}
		}
	}
}

詳細信息

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

input:


output:

Accepted: 18 34

result:

ok 

Test #2:

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

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

input:


output:

Accepted: 18 51

result:

ok 

Test #3:

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

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

input:


output:

Accepted: 18 68

result:

ok 

Test #4:

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

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

input:


output:

Accepted: 18 85

result:

ok 

Test #5:

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

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

input:


output:

Accepted: 18 102

result:

ok 

Test #6:

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

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #7:

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

input:

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #8:

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

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #9:

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

input:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #10:

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

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #11:

score: 1
Accepted
time: 4ms
memory: 3604kb

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #12:

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

input:

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

output:

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #13:

score: 1
Accepted
time: 4ms
memory: 3864kb

input:

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #14:

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

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #15:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #16:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #17:

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

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #18:

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

input:

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

output:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #19:

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

input:

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

output:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #20:

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

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

input:


output:

Accepted: 18 3400

result:

ok 

Subtask #2:

score: 9
Accepted

Test #21:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #22:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #23:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #24:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #25:

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

input:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #26:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #27:

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

input:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #28:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #29:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #30:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #31:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #32:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #33:

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

input:

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

output:

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

input:


output:

Accepted: 18 6834

result:

ok 

Test #34:

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

input:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #35:

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

input:

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

output:

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

input:


output:

Accepted: 18 6800

result:

ok 

Test #36:

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

input:

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

output:

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

input:


output:

Accepted: 18 3400

result:

ok 

Test #37:

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

input:

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

input:


output:

Accepted: 18 3400

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