QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#422276#67. Two Transportationslichenghan6 75ms19304kbC++205.3kb2024-05-27 10:32:482024-05-27 10:32:49

Judging History

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

  • [2024-05-27 10:32:49]
  • 评测
  • 测评结果:6
  • 用时:75ms
  • 内存:19304kb
  • [2024-05-27 10:32:48]
  • 提交

Azer

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

namespace nsa{
#ifndef LCH
#define printf(...) 1
#endif
	const int WB=9;
	const int NB=11;
	const int N=2002;
	int __rbits,__cur;
	
	int n;
	vector<pair<int,int>> g[N];
	int dis[N],vis[N],ac;
	int lstdi;
	priority_queue<pair<int,int>,vector<pair<int,int>>,
		greater<pair<int,int>>>q;
	int stat=0;
	// stat=0: waiting for val
	// stat=1: waiting for id
	
	void AwaitInt(int bits){ __cur=0,__rbits=bits; }
	void SendInt(int x,int bits){
		printf("Alice send %d (%c)\n",x,"WN"[bits==NB]);
		vector<int> bs;
		for(int i=0;i<bits;i++) bs.push_back(x&1),x>>=1;
		reverse(bs.begin(),bs.end());
		for(int i:bs) SendA(i);
	}
	void ext(int u){
		for(auto [v,w]:g[u]){
			if(dis[v]>dis[u]+w){
				dis[v]=dis[u]+w;
				q.push({dis[v],v});
			}
		}
	}
	void ReceiveInt(int x){
		printf("Alice receive %d\n",x);
		if(stat==0){
			if(x==505) x=1e9;
			else x+=lstdi;
			printf("%d is a value, check\n",x);
			int u;
			if(q.empty()){
				u=n;
			}else{
				u=q.top().second;
			}
			printf("cur dist is %d (%d), ",u,dis[u]);
			if(x<dis[u]){
				printf("await\n");
				lstdi=x;
				AwaitInt(NB);
				stat=1;
				return;
			}
			lstdi=dis[u];
			if(x>dis[u]){
				printf("better, send, ");
				SendInt(u,NB);
			}
			vis[u]=true;
			q.pop();
			printf("updt!\n");
			ext(u);
		}else{
			printf("%d is an id, updt dist\n",x);
			dis[x]=lstdi;
			vis[x]=true;
			ext(x);
			stat=0;
		}
		++ac;
		while(!q.empty()){
			assert(q.size()<=(unsigned)(n*n));
			int u=q.top().second;
			if(vis[u]){
				// printf("u = %d\n",u);
				q.pop();
				continue;
			}
			printf("new top is %d (%d)\n",u,dis[u]);
			SendInt(min(505,dis[u]-lstdi),WB);
			AwaitInt(WB);
			return;
		}
		if(ac<n){
			SendInt(505,WB);
			AwaitInt(WB);
		}
	}
#ifndef LCH
#undef printf
#endif
}

void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
		std::vector<int> C) {
	nsa::n=N;
	memset(nsa::dis,0x3f,(N+1)*sizeof(int));
	memset(nsa::vis,0,(N+1)*sizeof(int));
	nsa::ac=0;
	nsa::dis[0]=0;
	nsa::lstdi=0;
	nsa::stat=0;
	for(int i=0;i<N;i++) nsa::g[i].clear();
	for(int i=0;i<A;i++) nsa::g[U[i]].push_back({V[i],C[i]});
	for(int i=0;i<A;i++) nsa::g[V[i]].push_back({U[i],C[i]});
	nsa::q.push({0,0});
	nsa::SendInt(0,nsa::WB);
	nsa::AwaitInt(nsa::WB);
}

void ReceiveA(bool x) {
	if(!nsa::__rbits){
		fprintf(stderr,"Alice wants nothing but bob sends");
		exit(0);
	}
	nsa::__rbits--;
	nsa::__cur=(nsa::__cur<<1)+x;
	if(nsa::__rbits==0) nsa::ReceiveInt(nsa::__cur);
}

std::vector<int> Answer() {
	using namespace nsa;
	std::vector<int> ans(n);
	for(int k=0;k<n;++k) ans[k]=nsa::dis[k];
	return ans;
}

Baijan

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

namespace nsb{
#ifndef LCH
#define printf(...) 1
#endif
	const int WB=9;
	const int NB=11;
	const int N=2002;
	int __rbits,__cur;
	
	int n;
	vector<pair<int,int>> g[N];
	int dis[N],vis[N];
	int lstdi,ac;
	// stat: 0=waiting for val, 1=waiting for id, 2=end
	priority_queue<pair<int,int>,vector<pair<int,int>>,
		greater<pair<int,int>>>q;
	int stat=0;
	
	void AwaitInt(int bits){ __cur=0,__rbits=bits; }
	void SendInt(int x,int bits){
		printf("Bob send %d (%c)\n",x,"WN"[bits==NB]);
		vector<int> bs;
		for(int i=0;i<bits;i++) bs.push_back(x&1),x>>=1;
		reverse(bs.begin(),bs.end());
		for(int i:bs) SendB(i);
	}
	void ext(int u){
		for(auto [v,w]:g[u]){
			if(dis[v]>dis[u]+w){
				dis[v]=dis[u]+w;
				q.push({dis[v],v});
			}
		}
	}
	void ReceiveInt(int x){
		printf("Bob receive %d\n",x);
		if(stat==0){
			if(x==505) x=1e9;
			else x+=lstdi;
			printf("%d is a value, check\n",x);
			int u;
			if(q.empty()){
				u=n;
			}else{
				u=q.top().second;
			}
			printf("cur dist is %d (%d), ",u,dis[u]);
			if(x<dis[u]){
				printf("await\n");
				lstdi=x;
				AwaitInt(NB);
				stat=1;
				return;
			}
			lstdi=dis[u];
			if(x>dis[u]){
				printf("better, send, ");
				SendInt(u,NB);
			}
			vis[u]=true;
			q.pop();
			printf("updt!\n");
			ext(u);
		}else{
			printf("%d is an id, updt dist\n",x);
			dis[x]=lstdi;
			vis[x]=true;
			ext(x);
			stat=0;
		}
		++ac;
		while(!q.empty()){
			assert(q.size()<=(unsigned)(n*n));
			int u=q.top().second;
			if(vis[u]){
				q.pop();
				continue;
			}
			printf("new top is %d (%d)\n",u,dis[u]);
			SendInt(min(505,dis[u]-lstdi),WB);
			AwaitInt(WB);
			return;
		}
		if(ac<n){
			SendInt(505,WB);
			AwaitInt(WB);
		}
	}
#ifndef LCH
#undef printf
#endif
}

void InitB(int N, int B, std::vector<int> U, std::vector<int> V,
        std::vector<int> C) {
	nsb::n=N;
	memset(nsb::dis,0x3f,(N+1)*sizeof(int));
	memset(nsb::vis,0,(N+1)*sizeof(int));
	nsb::ac=0;
	nsb::dis[0]=0;
	nsb::lstdi=0;
	nsb::stat=0;
	for(int i=0;i<N;i++) nsb::g[i].clear();
	for(int i=0;i<B;i++) nsb::g[U[i]].push_back({V[i],C[i]});
	for(int i=0;i<B;i++) nsb::g[V[i]].push_back({U[i],C[i]});
	nsb::q.push({0,0});
	nsb::SendInt(0,nsb::WB);
	nsb::AwaitInt(nsb::WB);
}

void ReceiveB(bool y) {
	if(!nsb::__rbits){
		fprintf(stderr,"Bob wants nothing but alice sends");
		exit(0);
	}
	nsb::__rbits--;
	nsb::__cur=(nsb::__cur<<1)+y;
	if(nsb::__rbits==0) nsb::ReceiveInt(nsb::__cur);
}

详细

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 6ms
memory: 4292kb

input:

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

output:

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

input:


output:

0
2417
4435
3092
3018
2637
2136
3353
4117
2498
3522
3354
2776
1912
3232
3382
2310
2867
3546
2681
2605
3912
3045
3311
1307
2094
1352
3087
3487
3865
3223
4033
3647
2816
2468
1263
2756
3086
1735
3002
2385
2754
2837
3718
2891
2201
3478
3041
2726
3012
2634
2599
914
3509
4886
2317
4081
1993
2391
2749
3551...

result:

ok 2000 lines

Test #2:

score: 6
Accepted
time: 0ms
memory: 3848kb

input:

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

output:

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

input:


output:

0

result:

ok single line: '0'

Test #3:

score: 6
Accepted
time: 13ms
memory: 4020kb

input:

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

output:

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

input:


output:

0
396305
456652
146790
45193
157298
290069
106100
444511
21734
496244
290946
448070
521134
597482
523834
252545
359818
556162
571923
74738
478958
576152
13164
3449
20598
191933
480791
549865
358479
85064
194758
230237
199091
240511
264959
272630
506097
508042
437901
345079
203449
238730
170044
35181...

result:

ok 2000 lines

Test #4:

score: 6
Accepted
time: 38ms
memory: 12708kb

input:

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

output:

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

input:


output:

0
3448
958
4288
8681
336
148
3141
6232
8253
676
8417
4301
7395
2583
2332
1931
5600
7707
6421
1048
3951
3221
1394
6384
4563
4421
2439
5778
5223
3112
7250
7987
2207
564
5006
4104
2143
1953
2367
3895
5571
5608
8505
3836
8925
1735
5333
2756
2154
3381
4181
7200
9010
3640
5480
3088
5385
4089
2931
8673
454...

result:

ok 2000 lines

Test #5:

score: 6
Accepted
time: 1ms
memory: 4076kb

input:

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

output:

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

input:


output:

0
45
26
35
27
44
28
19
40
28
26
24
33
56
20
33
32
45
13
24
29
34
20
30
35
52
33
35
22
45
32
42
29
33
35
53
35
11
53
28
28
44
32
46
39
39
56
87
36
18
28
37
38
40
52
36
36
33
36
32
36
26
30
37
31
38
43
7
50
24
48
40
37
48
37
27
37
43
47
43
32
31
31
43
35
40
51
37
45
37
15
25
34
40
34
23
34
38
33
54

result:

ok 100 lines

Test #6:

score: 6
Accepted
time: 13ms
memory: 5412kb

input:

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

output:

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

input:


output:

0
170
114
124
149
133
109
128
102
102
129
94
138
137
50
153
93
92
127
100
145
136
112
155
172
104
114
132
136
140
139
111
135
24
74
117
99
115
107
87
138
96
76
174
132
110
101
134
128
99
93
82
128
94
102
97
123
160
116
151
104
84
98
220
145
126
144
74
132
148
81
103
138
161
133
88
81
127
122
167
102...

result:

ok 2000 lines

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 8
Accepted
time: 1ms
memory: 3884kb

input:

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

output:

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

input:


output:

0

result:

ok single line: '0'

Test #8:

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

input:

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

output:

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

input:


output:

0
128264
331628
384182
208153
525372
572423
144082
259414
406719
308409
557889
129397
285792
216221
486927
571225
149599
317887
440746
229109
307465
104346
97136
445388
611196
462442
152511
595507
317479
409647
118010
508691
325383
250598
85753
552333
387494
470667
87406
390547
180339
101478
64178
2...

result:

ok 2000 lines

Test #9:

score: 8
Accepted
time: 8ms
memory: 3996kb

input:

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

output:

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

input:


output:

0
146596
486541
542861
502560
183150
412880
64845
101068
278420
276251
427456
76218
143112
209207
558065
307241
614514
208920
287802
355682
281972
181079
523222
206539
34041
323247
426483
47638
205160
104524
292282
131653
145869
480792
82385
485370
530341
131178
574749
543107
343884
191191
164986
35...

result:

ok 2000 lines

Test #10:

score: 8
Accepted
time: 62ms
memory: 9472kb

input:

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

output:

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

input:


output:

0
2248
1885
378
1566
1525
309
666
1857
2847
758
1494
2486
2597
2582
457
2369
1571
1189
2272
2264
1745
937
2057
98
2765
2333
1334
2953
192
2317
1318
825
2297
158
388
1256
1467
2758
1741
593
1760
1844
1051
745
1365
2911
2660
2563
2470
2722
2325
2300
1399
2410
2147
1061
2146
2642
541
2740
2138
38
2803
...

result:

ok 2000 lines

Test #11:

score: 8
Accepted
time: 63ms
memory: 9260kb

input:

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

output:

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

input:


output:

0
13
14
15
13
11
11
16
8
9
15
12
10
12
11
13
15
16
15
12
14
10
13
13
12
11
13
15
15
12
15
12
9
12
15
15
14
15
12
12
7
14
17
11
15
13
10
12
11
9
17
11
13
13
15
15
12
11
15
13
14
11
14
14
14
14
11
11
13
12
11
14
12
14
13
14
13
11
15
12
15
9
11
12
13
3
3
15
11
14
13
10
12
10
13
12
15
12
12
17
12
12
14
...

result:

ok 2000 lines

Test #12:

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

input:

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

output:

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

input:


output:

0
588
828
680
367
984
784
697
790
734
680
803
1146
537
462
648
599
599
675
537
731
524
1264
746
741
427
729
1091
754
762
765
849
739
509
1152
519
631
626
330
941
851
643
456
1030
548
792
603
526
507
686
502
423
654
967
672
700
630
919
727
752
865
1175
541
615
660
757
668
674
746
669
716
722
656
773
...

result:

ok 411 lines

Test #13:

score: 0
Wrong Answer
time: 66ms
memory: 9244kb

input:

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

output:

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

input:


output:


result:

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

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 5ms
memory: 3948kb

input:

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

output:

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

input:


output:

0
3328
4161
4895
4209
3745
3720
1061109567
3313
4008
2104
1061109567
3666
3501
1061109567
3359
4244
1061109567
1906
392
2028
3840
1061109567
2376
3001
5530
2494
3340
1061109567
3653
3624
1061109567
4121
2243
4252
2165
4289
1061109567
6032
1061109567
1061109567
1362
1061109567
1061109567
1061109567
6...

result:

wrong answer 8th lines differ - expected: '4315', found: '1061109567'

Subtask #4:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 0ms
memory: 3928kb

input:

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

output:

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

input:


output:

0
1061109567
1737
1168
3083
1061109567
3240
1061109567
1061109567
3069
1616
1782
2120
1261
1061109567
1061109567
2536
2081
2469
1061109567
1175
2320
1061109567
2144
1061109567
1061109567
1769
1061109567
1061109567
3112
1061109567
2562
1266
1923
1061109567
1061109567
1061109567
2161
3587
1380
1928
20...

result:

wrong answer 2nd lines differ - expected: '1881', found: '1061109567'

Subtask #5:

score: 0
Wrong Answer

Test #38:

score: 0
Wrong Answer
time: 2ms
memory: 3932kb

input:

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

output:

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

input:


output:

0
1061109567
3039
3862
1061109567
1061109567
3258
4604
3860
2661
1061109567
3113
2706
3757
4805
4448
1061109567
3163
1061109567
1061109567
3500
3334
3197
2491
4036
2868
1061109567
4219
2747
3122
1061109567
2314
3397
3285
1061109567
2031
2187
1061109567
3654
3459
3114
1061109567
1499
5106
3000
3488
3...

result:

wrong answer 2nd lines differ - expected: '3467', found: '1061109567'

Subtask #6:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 6ms
memory: 3944kb

input:

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

output:

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

input:


output:

0
4745
1061109567
5133
4107
3809
1061109567
3569
3801
3371
5482
4438
4540
1609
3082
1061109567
5097
2942
1061109567
3617
3593
1061109567
4473
4646
1061109567
4752
2852
1061109567
4756
2996
4071
3100
3564
2168
4235
1061109567
4666
4920
5046
3687
1061109567
1693
3180
1061109567
1061109567
1061109567
3...

result:

wrong answer 3rd lines differ - expected: '3326', found: '1061109567'

Subtask #7:

score: 0
Wrong Answer

Test #64:

score: 16
Accepted
time: 3ms
memory: 4072kb

input:

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

output:

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

input:


output:

0
25855
513884
451446
379664
463677
147972
259014
115396
537065
61376
510191
95200
328777
282337
199131
72153
405843
215292
529082
413220
99569
275396
215884
52889
281825
182731
64473
510973
545141
417123
190844
319517
483688
15462
490221
521781
384795
539004
457181
146029
122086
1730
31958
265013
7...

result:

ok 2000 lines

Test #65:

score: 16
Accepted
time: 74ms
memory: 19304kb

input:

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

output:

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

input:


output:

0
6187
1398
17
6163
4742
4598
2337
2237
6475
6001
5268
2245
6132
4925
1482
4253
1962
6642
2449
2704
3396
5449
2492
706
835
1879
3203
6855
4265
546
1231
2390
2300
4651
1353
1673
6724
6753
360
4275
6749
3400
1385
2945
6010
5339
226
2511
4558
1033
4708
4330
1882
1185
3535
5071
3843
1252
110
6571
6727
3...

result:

ok 2000 lines

Test #66:

score: 16
Accepted
time: 75ms
memory: 17444kb

input:

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

output:

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

input:


output:

0
5455
4313
3996
4463
4115
2413
1141
7939
4669
5854
7806
7612
3394
7713
441
4956
1630
751
2070
4241
6754
3518
3736
3158
549
4590
6798
842
1597
7637
3679
6104
7953
5654
3951
1877
2075
5983
6633
5724
2967
2362
527
7670
3759
3471
4089
508
1187
5437
3533
3003
7429
7499
5966
7484
949
1545
1862
542
3370
1...

result:

ok 2000 lines

Test #67:

score: 0
Wrong Answer
time: 4ms
memory: 4340kb

input:

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

output:

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

input:


output:

0
80197
82299
44473
18072
2475
28130
2301
83463
113875
81326
59249
90428
50231
85700
74524
46729
16457
25617
101665
68900
35355
33610
23903
86933
47102
83571
7583
34127
133340
110254
37732
129866
45351
60945
72461
55392
52316
131114
124908
30075
15677
88832
133708
133161
36589
62634
64887
16069
1163...

result:

wrong answer 2nd lines differ - expected: '79964', found: '80197'