QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725047#6202. 小 C 的比赛NineSuns100 ✓82ms5660kbC++14863b2024-11-08 16:01:462024-11-08 16:01:52

Judging History

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

  • [2024-11-08 16:01:52]
  • 评测
  • 测评结果:100
  • 用时:82ms
  • 内存:5660kb
  • [2024-11-08 16:01:46]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
const int N = 5e5+5, inf = 0x3f3f3f3f; 
int n, c[5], cc[5], a[N]; 

bool chk (int k) {
	int s, mn; s = mn = 0;
	for (int i = 0;i < 5;i++) cc[i] = c[i];  
	for (int i = 1;i <= n;i++) {
		int fl = 0; 
		for (int j = 4;j >= 0;j--) if (cc[j] && s+(j-2)-mn <= k) {
			cc[j]--; s += j-2; a[i] = j-2; mn = min(mn, s); fl = 1; break;  
		}
		if (!fl) return 0; 
	}
	return 1; 
}

void solve () {
	n = 0; 
	for (int i = 0;i < 5;i++) cin >> c[i], n += c[i]; 
	int l = -2, r = inf; 
	while (l < r) {
		int mid = l+r>>1; 
		if (chk(mid)) r = mid;
		else l = mid+1; 
	}
	cout << l << "\n"; 
	chk(l); 
	for (int i = 1;i <= n;i++) cout << a[i] << " "; cout << "\n"; 
}

int main () {
	ios::sync_with_stdio(0); 
	cin.tie(0); cout.tie(0); 
	int T; cin >> T;
	while (T--) solve(); 
	return 0; 
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 18
Accepted

Test #1:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
8 2 5 2 3
0 0 1 19 0
19 0 1 0 0
0 18 0 0 2
2 13 3 0 2

output:

2
2 0 0 0 0 0 -1 1 -1 1 -2 2 -2 2 -2 -2 -2 -2 -2 -2 
19
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
0
0 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
2
2 0 0 0 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 

result:

ok djq dxm tie tie

Test #2:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
3 11 2 2 2
2 8 3 2 5
8 4 3 1 4
2 1 2 1 14
1 2 2 4 11

output:

2
2 0 0 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 
2
2 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 -2 
2
2 0 0 0 -1 1 -1 -1 2 -1 -2 2 -2 2 -2 -2 -2 -2 -2 -2 
24
2 2 2 2 2 2 2 2 2 2 2 2 0 0 -1 1 -2 2 -2 2 
22
2 2 2 2 2 2 2 2 2 2 2 0 0 -1 1 -1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #3:

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

input:

5
3 1 3 6 7
9 0 0 11 0
17 0 1 2 0
12 7 1 0 0
11 6 1 1 1

output:

13
2 2 2 2 2 2 1 0 0 0 -1 1 -2 2 -2 1 1 -2 1 1 
2
1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 
1
1 0 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
0
0 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #4:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
1 0 1 0 18
1 12 2 2 3
0 1 0 19 0
0 6 1 0 13
1 0 0 16 3

output:

34
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -2 2 
2
2 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -2 
18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 
20
2 2 2 2 2 2 2 2 2 2 0 -1 -1 2 -1 -1 2 -1 -1 2 
20
2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #5:

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

input:

5
3 10 3 3 1
3 2 1 12 2
0 0 1 11 8
11 3 1 5 0
2 12 2 0 4

output:

2
2 0 0 0 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 
8
2 2 1 1 1 1 0 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 
27
2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 0 
1
1 0 -1 1 -1 1 -1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -2 -2 

result:

ok djq dxm tie tie

Test #6:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
0 15 0 0 5
0 17 2 0 1
2 0 2 4 12
1 1 3 0 15
1 0 2 4 13

output:

2
2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 
2
2 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
24
2 2 2 2 2 2 2 2 2 2 2 2 0 0 -2 1 1 -2 1 1 
27
2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 2 -2 2 
28
2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 0 0 -2 1 1 

result:

ok djq dxm tie tie

Test #7:

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

input:

5
12 1 0 6 1
5 11 0 2 2
1 2 2 9 6
0 10 0 1 9
17 0 2 1 0

output:

2
2 -1 1 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 
17
2 2 2 2 2 2 1 1 1 1 1 0 0 -1 1 -1 1 -2 1 1 
9
2 2 2 2 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
1
1 0 0 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #8:

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

input:

5
2 1 2 11 4
18 0 0 0 2
0 6 2 0 12
0 0 0 1 19
2 12 2 1 3

output:

14
2 2 2 2 1 1 1 1 1 1 0 0 -1 1 -2 1 1 -2 1 1 
2
2 -2 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
18
2 2 2 2 2 2 2 2 2 0 0 -1 -1 2 -1 -1 2 -1 -1 2 
39
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 
2
2 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -2 -2 

result:

ok djq dxm tie tie

Test #9:

score: 18
Accepted
time: 0ms
memory: 3632kb

input:

5
6 14 0 0 0
3 9 5 2 1
17 0 0 3 0
3 0 2 15 0
1 4 1 1 13

output:

-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 
2
2 0 0 0 0 0 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 
1
1 -2 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
9
1 1 1 1 1 1 1 1 1 0 0 -2 1 1 -2 1 1 -2 1 1 
21
2 2 2 2 2 2 2 2 2 2 1 0 -1 -1 2 -1 -1 2 -2 2 

result:

ok djq dxm tie tie

Test #10:

score: 18
Accepted
time: 0ms
memory: 3684kb

input:

5
16 4 0 0 0
0 0 0 5 15
2 0 1 15 2
0 13 1 0 6
9 11 0 0 0

output:

-1
-1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
35
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 
15
2 2 1 1 1 1 1 1 1 1 1 1 1 0 -2 1 1 -2 1 1 
2
2 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #11:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
11 0 1 7 1
12 4 1 2 1
4 13 2 1 0
1 1 3 0 15
11 0 3 5 1

output:

2
2 0 -2 1 1 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 1 -1 1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
1
1 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 
27
2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 2 -2 2 
2
2 0 0 0 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #12:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
0 12 0 0 8
1 3 6 2 8
1 6 2 1 10
0 4 2 1 13
10 9 1 0 0

output:

4
2 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
13
2 2 2 2 2 2 1 0 0 0 0 0 0 -1 1 -1 -1 2 -2 2 
13
2 2 2 2 2 2 1 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 
23
2 2 2 2 2 2 2 2 2 2 2 1 0 0 -1 -1 2 -1 -1 2 
0
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #13:

score: 18
Accepted
time: 0ms
memory: 3584kb

input:

5
1 15 0 1 3
1 0 1 17 1
6 6 4 2 2
7 12 1 0 0
0 0 0 20 0

output:

2
2 -1 1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 
17
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -2 1 1 
2
2 0 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 -2 -2 -2 -2 -2 -2 
0
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 
20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok djq dxm tie tie

Test #14:

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

input:

5
0 1 0 0 19
2 6 6 4 2
9 8 1 0 2
15 1 0 1 3
0 8 3 1 8

output:

37
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 
2
2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -2 -2 
2
2 0 -1 -1 2 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 -1 1 -2 2 -2 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
9
2 2 2 2 1 0 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 

result:

ok djq dxm tie tie

Test #15:

score: 18
Accepted
time: 0ms
memory: 3620kb

input:

5
17 2 0 0 1
2 1 4 10 3
14 5 1 0 0
4 0 0 16 0
13 3 1 0 3

output:

2
2 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
11
2 2 2 1 1 1 1 1 0 0 0 0 -1 1 -2 1 1 -2 1 1 
0
0 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
8
1 1 1 1 1 1 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
2
2 0 -1 -1 2 -1 -2 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #16:

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

input:

5
3 2 0 1 14
9 7 1 1 2
5 6 5 3 1
0 6 1 1 12
2 3 6 3 6

output:

21
2 2 2 2 2 2 2 2 2 2 1 -1 -1 2 -2 2 -2 2 -2 2 
2
2 0 -1 1 -1 -1 2 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 0 0 0 0 -1 1 -1 1 -1 1 -1 -1 -1 -2 -2 -2 -2 -2 
19
2 2 2 2 2 2 2 2 2 1 0 -1 -1 2 -1 -1 2 -1 -1 2 
8
2 2 2 2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -2 2 -2 2 

result:

ok djq dxm tie tie

Test #17:

score: 18
Accepted
time: 0ms
memory: 3588kb

input:

5
1 1 0 17 1
0 1 0 19 0
9 2 2 2 5
2 7 2 3 6
2 1 1 4 12

output:

16
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 -2 1 1 
18
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 
2
2 0 0 -1 1 -1 1 -2 2 -2 2 -2 2 -2 2 -2 -2 -2 -2 -2 
4
2 2 0 0 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -2 2 -2 2 
23
2 2 2 2 2 2 2 2 2 2 2 1 0 -1 1 -2 2 -2 1 1 

result:

ok djq dxm tie tie

Test #18:

score: 18
Accepted
time: 1ms
memory: 3636kb

input:

5
0 1 1 1 17
4 4 2 7 3
4 9 3 3 1
4 13 1 1 1
17 1 1 0 1

output:

34
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 1 
2
2 0 0 -1 1 -1 1 -1 1 -1 1 -2 2 -2 2 -2 1 1 -2 1 
2
2 0 0 0 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 
2
2 0 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 
2
2 0 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #19:

score: 18
Accepted
time: 0ms
memory: 3652kb

input:

5
2 1 2 1 14
1 3 0 0 16
7 2 6 4 1
1 3 3 0 13
14 5 1 0 0

output:

24
2 2 2 2 2 2 2 2 2 2 2 2 0 0 -1 1 -2 2 -2 2 
27
2 2 2 2 2 2 2 2 2 2 2 2 2 -1 2 -1 -1 2 -2 2 
2
2 0 0 0 0 0 0 -1 1 -1 1 -2 1 1 -2 -2 -2 -2 -2 -2 
21
2 2 2 2 2 2 2 2 2 2 0 0 0 -1 2 -1 -1 2 -2 2 
0
0 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #20:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
1 13 2 0 4
9 2 3 5 1
1 0 0 18 1
6 13 0 0 1
13 6 1 0 0

output:

2
2 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -2 
2
2 0 0 0 -1 1 -1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 
18
2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -2 1 1 
2
2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 
0
0 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #21:

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

input:

5
1 0 0 3 16
7 13 0 0 0
2 2 2 9 5
7 2 3 5 3
9 11 0 0 0

output:

33
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 -2 1 1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 
13
2 2 2 2 2 1 1 1 0 0 -1 1 -1 1 -2 1 1 -2 1 1 
2
2 0 0 0 -1 1 -1 1 -2 2 -2 2 -2 1 1 -2 1 -2 -2 -2 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #22:

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

input:

5
11 1 0 6 2
4 3 4 3 6
4 15 1 0 0
7 8 1 3 1
1 4 4 10 1

output:

2
2 -1 1 -2 2 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 
4
2 2 0 0 0 0 -1 1 -1 1 -1 1 -2 2 -2 2 -2 2 -2 2 
0
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 
2
2 0 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 
6
2 1 1 1 1 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #23:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
15 1 2 1 1
3 1 2 12 2
9 0 1 10 0
0 4 2 0 14
0 4 2 1 13

output:

2
2 0 0 -1 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
9
2 2 1 1 1 1 1 0 0 -1 1 -2 1 1 -2 1 1 -2 1 1 
1
1 0 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 
24
2 2 2 2 2 2 2 2 2 2 2 2 0 0 -1 -1 2 -1 -1 2 
23
2 2 2 2 2 2 2 2 2 2 2 1 0 0 -1 -1 2 -1 -1 2 

result:

ok djq dxm tie tie

Test #24:

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

input:

5
14 2 1 3 0
0 4 0 0 16
0 0 0 6 14
6 9 0 3 2
2 4 2 1 11

output:

1
1 0 -1 1 -1 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
28
2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 -1 2 -1 -1 2 
34
2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 
2
2 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 
15
2 2 2 2 2 2 2 1 0 0 -1 -1 2 -1 -1 2 -2 2 -2 2 

result:

ok djq dxm tie tie

Test #25:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
0 1 2 10 7
17 0 1 2 0
12 8 0 0 0
1 1 1 12 5
10 8 1 0 1

output:

23
2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 0 0 -1 1 
1
1 0 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
19
2 2 2 2 2 1 1 1 1 1 1 1 1 1 0 -1 1 -2 1 1 
2
2 0 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #26:

score: 18
Accepted
time: 0ms
memory: 3716kb

input:

5
0 0 0 15 5
0 2 4 8 6
6 5 3 4 2
6 12 1 0 1
18 2 0 0 0

output:

25
2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
18
2 2 2 2 2 2 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 
2
2 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 -2 2 -2 -2 -2 -2 -2 
2
2 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 
-1
-1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #27:

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

input:

5
0 16 1 2 1
7 8 0 2 3
3 1 4 6 6
5 0 1 13 1
8 6 2 1 3

output:

2
2 0 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
2
2 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 -2 -2 -2 -2 -2 -2 -2 
11
2 2 2 2 2 1 0 0 0 0 -1 1 -2 2 -2 1 1 -2 1 1 
5
2 1 1 1 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
2
2 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #28:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
4 0 1 14 1
2 3 3 3 9
5 0 2 11 2
1 1 0 7 11
11 0 0 9 0

output:

8
2 1 1 1 1 1 1 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
14
2 2 2 2 2 2 2 0 0 0 -1 1 -1 1 -1 1 -2 2 -2 2 
5
2 2 1 0 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
26
2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 -1 1 -2 1 1 
1
1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 -2 -2 

result:

ok djq dxm tie tie

Test #29:

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

input:

5
0 14 0 0 6
0 0 2 16 2
7 9 0 2 2
4 1 3 4 8
0 0 1 7 12

output:

2
2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 
20
2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
2
2 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 
11
2 2 2 2 2 1 0 0 0 -1 1 -2 2 -2 2 -2 2 -2 1 1 
31
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 0 

result:

ok djq dxm tie tie

Test #30:

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

input:

5
8 1 3 4 4
4 0 0 14 2
0 4 3 0 13
6 7 1 3 3
14 6 0 0 0

output:

2
2 0 0 0 -1 1 -2 2 -2 2 -2 2 -2 1 1 -2 1 -2 -2 -2 
10
2 2 1 1 1 1 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
22
2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 -1 2 -1 -1 2 
2
2 0 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -2 -2 -2 -2 -2 -2 
-1
-1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #31:

score: 18
Accepted
time: 0ms
memory: 3580kb

input:

5
0 6 3 1 10
8 4 1 7 0
9 4 0 6 1
10 2 4 3 1
5 8 4 0 3

output:

15
2 2 2 2 2 2 2 1 0 0 0 -1 -1 2 -1 -1 2 -1 -1 2 
1
1 0 -1 1 -1 1 -1 1 -1 1 -2 1 -2 1 -2 -2 -2 -2 -2 -2 
2
2 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 0 0 0 -1 1 -1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 0 0 0 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #32:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
13 1 3 2 1
1 1 2 10 6
1 3 1 2 13
2 10 4 3 1
1 8 0 0 11

output:

2
2 0 0 0 -1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
19
2 2 2 2 2 2 1 1 1 1 1 1 1 0 0 -1 1 -2 1 1 
23
2 2 2 2 2 2 2 2 2 2 2 1 0 -1 1 -1 -1 2 -2 2 
2
2 0 0 0 0 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 -2 
12
2 2 2 2 2 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 

result:

ok djq dxm tie tie

Test #33:

score: 18
Accepted
time: 0ms
memory: 3636kb

input:

5
0 10 1 2 7
9 7 2 1 1
1 5 1 0 13
20 0 0 0 0
0 20 0 0 0

output:

6
2 2 2 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2
2 0 0 -1 1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
19
2 2 2 2 2 2 2 2 2 0 -1 2 -1 -1 2 -1 -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 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 

result:

ok djq dxm tie tie

Test #34:

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

input:

5
2 9 3 1 5
1 1 3 7 8
9 0 1 10 0
7 9 1 2 1
2 2 2 12 2

output:

2
2 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 -2 
20
2 2 2 2 2 2 2 2 1 1 1 1 0 0 0 -1 1 -2 1 1 
1
1 0 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 
2
2 0 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 
10
2 2 1 1 1 1 1 1 0 0 -1 1 -1 1 -2 1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #35:

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

input:

5
0 2 2 8 8
0 0 1 2 17
2 16 2 0 0
1 9 2 2 6
0 1 0 4 15

output:

22
2 2 2 2 2 2 2 2 1 1 1 1 1 1 0 0 -1 1 -1 1 
36
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 0 
0
0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 
3
2 1 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 
33
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 -1 1 

result:

ok djq dxm tie tie

Test #36:

score: 18
Accepted
time: 0ms
memory: 3584kb

input:

5
0 0 1 3 16
3 1 2 5 9
6 9 2 2 1
0 7 1 0 12
8 8 3 1 0

output:

35
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 0 
16
2 2 2 2 2 2 2 2 0 0 -1 1 -2 2 -2 1 1 -2 1 1 
2
2 0 0 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 
17
2 2 2 2 2 2 2 2 0 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
1
1 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #37:

score: 18
Accepted
time: 0ms
memory: 3660kb

input:

5
4 0 1 14 1
0 0 2 13 5
2 0 2 1 15
1 2 1 12 4
0 0 0 17 3

output:

8
2 1 1 1 1 1 1 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
23
2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 
27
2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 0 -2 2 -2 2 
16
2 2 2 2 1 1 1 1 1 1 1 1 0 -1 1 -1 1 -2 1 1 
23
2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok djq dxm tie tie

Test #38:

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

input:

5
0 9 1 0 10
0 17 1 0 2
12 8 0 0 0
2 3 1 7 7
2 1 3 6 8

output:

11
2 2 2 2 2 0 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2
2 0 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
14
2 2 2 2 2 2 2 0 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 
17
2 2 2 2 2 2 2 2 1 0 0 0 -1 1 -2 1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #39:

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

input:

5
6 0 1 10 3
0 12 0 0 8
2 1 2 14 1
4 1 0 15 0
2 9 5 2 2

output:

4
2 2 0 -2 2 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
4
2 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
11
2 1 1 1 1 1 1 1 1 1 0 0 -1 1 -2 1 1 -2 1 1 
6
1 1 1 1 1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
2
2 0 0 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -2 -2 

result:

ok djq dxm tie tie

Test #40:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
0 0 1 13 6
5 2 1 8 4
10 1 4 1 4
0 0 0 4 16
11 3 3 1 2

output:

25
2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 
4
2 2 0 -1 1 -1 1 -2 2 -2 2 -2 1 1 -2 1 1 -2 1 1 
2
2 0 0 0 0 -1 1 -2 2 -2 2 -2 2 -2 -2 -2 -2 -2 -2 -2 
36
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 
2
2 0 0 0 -1 1 -1 -1 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #41:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
7 1 1 8 3
0 0 4 16 0
5 11 1 1 2
1 1 0 5 13
11 9 0 0 0

output:

2
2 0 -1 1 -2 2 -2 2 -2 1 1 -2 1 1 -2 1 1 -2 1 -2 
16
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 
2
2 0 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 
28
2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 -1 1 -2 1 1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #42:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
0 12 1 2 5
0 0 0 13 7
19 1 0 0 0
0 0 0 4 16
13 7 0 0 0

output:

2
2 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 
27
2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 
-1
-1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
36
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 
-1
-1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 

result:

ok djq dxm tie tie

Test #43:

score: 18
Accepted
time: 0ms
memory: 3584kb

input:

5
0 0 2 3 15
14 0 0 6 0
13 4 1 1 1
1 0 2 10 7
1 19 0 0 0

output:

33
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 0 0 
1
1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
22
2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 -2 1 1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 

result:

ok djq dxm tie tie

Test #44:

score: 18
Accepted
time: 0ms
memory: 3600kb

input:

5
4 4 6 5 1
0 4 1 0 15
13 4 1 1 1
3 10 3 1 3
0 17 0 1 2

output:

2
2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 -2 -2 -2 
26
2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 -1 2 -1 -1 2 
2
2 0 -1 1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -2 -2 -2 
2
2 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 

result:

ok djq dxm tie tie

Test #45:

score: 18
Accepted
time: 0ms
memory: 3588kb

input:

5
0 0 0 18 2
15 1 0 3 1
17 0 1 2 0
0 0 1 5 14
1 1 2 15 1

output:

22
2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
2
2 -1 1 -2 1 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
1
1 0 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
33
2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 0 
14
2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 -1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #46:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
6 14 0 0 0
10 8 1 0 1
1 19 0 0 0
5 14 1 0 0
18 1 0 1 0

output:

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

result:

ok djq dxm tie tie

Test #47:

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

input:

5
0 0 0 20 0
3 11 4 1 1
3 12 2 1 2
1 0 2 5 12
1 5 4 2 8

output:

20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
2
2 0 0 0 0 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 
2
2 0 0 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 
27
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 0 0 -2 1 1 
11
2 2 2 2 2 1 0 0 0 0 -1 1 -1 -1 2 -1 -1 2 -2 2 

result:

ok djq dxm tie tie

Test #48:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
18 2 0 0 0
1 16 1 1 1
5 1 1 12 1
0 1 2 5 12
1 1 0 6 12

output:

-1
-1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 
3
2 1 0 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
28
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 0 0 -1 1 
27
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 -1 1 -2 1 1 

result:

ok djq dxm tie tie

Test #49:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
1 11 3 4 1
14 5 1 0 0
0 0 0 5 15
5 6 3 1 5
0 0 0 0 20

output:

2
2 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -2 
0
0 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
35
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 
2
2 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -2 2 -2 2 -2 -2 -2 
40
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 

result:

ok djq dxm tie tie

Test #50:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
0 20 0 0 0
1 0 2 6 11
8 9 1 0 2
19 1 0 0 0
0 15 1 0 4

output:

-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
26
2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 0 0 -2 1 1 
2
2 0 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 
-1
-1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 

result:

ok djq dxm tie tie

Subtask #2:

score: 18
Accepted

Dependency #1:

100%
Accepted

Test #51:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
6 30 3 0 1
1 0 2 27 10
3 2 2 14 19
3 0 0 17 20
32 6 1 0 1

output:

2
2 0 0 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 -2 -2 -2 -2 -2 -2 
45
2 2 2 2 2 2 2 2 2 2 1 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 -2 1 1 
44
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 0 0 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 
51
2 2 ...

result:

ok djq dxm tie tie

Test #52:

score: 18
Accepted
time: 1ms
memory: 3648kb

input:

5
0 1 2 4 33
13 18 2 2 5
0 0 0 7 33
9 12 6 7 6
2 7 0 1 30

output:

69
2 2 2 2 2 2 2 2 2 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 1 1 0 0 -1 1 
2
2 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
73
2 2 2 2 2 2 2 2 2 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 1 1 1 1 1 1 
2
2 0 0 0 0 0 0 -...

result:

ok djq dxm tie tie

Test #53:

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

input:

5
16 12 4 3 5
25 9 2 3 1
2 30 2 1 5
0 40 0 0 0
38 0 1 1 0

output:

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

result:

ok djq dxm tie tie

Test #54:

score: 18
Accepted
time: 0ms
memory: 3632kb

input:

5
10 3 2 23 2
29 1 2 7 1
25 2 2 8 3
2 0 1 37 0
12 15 4 3 6

output:

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

result:

ok djq dxm tie tie

Test #55:

score: 18
Accepted
time: 0ms
memory: 3652kb

input:

5
1 2 3 2 32
14 22 3 1 0
20 2 0 17 1
5 4 1 4 26
22 15 2 0 1

output:

62
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 1 -1 1 -2 2 
1
1 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2...

result:

ok djq dxm tie tie

Test #56:

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

input:

5
4 19 7 4 6
11 24 1 3 1
5 27 2 5 1
8 29 2 0 1
8 0 1 31 0

output:

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

result:

ok djq dxm tie tie

Test #57:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
1 31 2 1 5
36 0 0 4 0
0 0 2 0 38
2 0 2 36 0
0 34 3 2 1

output:

2
2 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 
1
1 -2 1 -2 1 -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 
76
2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #58:

score: 18
Accepted
time: 0ms
memory: 3660kb

input:

5
1 0 0 15 24
28 8 1 1 2
1 1 0 8 30
30 3 2 3 2
21 6 2 4 7

output:

61
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 1 1 1 1 1 1 1 1 1 1 1 1 -2 1 1 
2
2 0 -1 1 -1 -1 2 -1 -1 -1 -1 -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 
65
2 2 2 2 2 2 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 1 1 1 1 -1 1 -2 1 1 
2
2 0 0 -1...

result:

ok djq dxm tie tie

Test #59:

score: 18
Accepted
time: 0ms
memory: 3588kb

input:

5
0 1 2 7 30
0 26 0 0 14
19 15 2 2 2
1 3 1 13 22
0 33 0 0 7

output:

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

result:

ok djq dxm tie tie

Test #60:

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

input:

5
23 14 1 2 0
12 17 3 5 3
17 22 1 0 0
2 1 0 37 0
1 0 3 25 11

output:

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

result:

ok djq dxm tie tie

Test #61:

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

input:

5
4 4 3 29 0
8 2 1 29 0
3 0 2 23 12
6 1 5 22 6
24 5 4 6 1

output:

17
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
11
1 1 1 1 1 1 1 1 1 1 1 0 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
41
2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 -2 1 1 -2 1 1 -2 1 1 
21
2 2 2 2 2 2 1 1 1 1 1 1 ...

result:

ok djq dxm tie tie

Test #62:

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

input:

5
11 3 4 19 3
2 5 5 1 27
0 39 1 0 0
0 3 4 30 3
0 5 4 0 31

output:

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

result:

ok djq dxm tie tie

Test #63:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
6 2 1 29 2
7 1 4 27 1
24 8 3 2 3
4 25 2 1 8
4 5 6 9 16

output:

19
2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
14
2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
2
2 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -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...

result:

ok djq dxm tie tie

Test #64:

score: 18
Accepted
time: 0ms
memory: 3652kb

input:

5
0 19 0 0 21
4 19 3 2 12
1 4 3 6 26
0 0 0 40 0
2 33 2 1 2

output:

23
2 2 2 2 2 2 2 2 2 2 2 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2
2 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -2 2 -2 2 -2 2 -2 
52
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 
40...

result:

ok djq dxm tie tie

Test #65:

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

input:

5
11 16 8 4 1
6 3 3 7 21
29 9 1 0 1
2 3 3 28 4
13 25 1 1 0

output:

2
2 0 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
34
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 1 -1 1 -1 1 -2 2 -2 2 -2 2 -2 2 -2 1 1 -2 1 1 
2
2 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -...

result:

ok djq dxm tie tie

Test #66:

score: 18
Accepted
time: 0ms
memory: 3648kb

input:

5
2 25 2 0 11
0 0 0 38 2
1 6 2 0 31
2 18 3 4 13
21 19 0 0 0

output:

2
2 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -2 -2 
42
2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
54
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 
8
2 2 2 2 0 0 0...

result:

ok djq dxm tie tie

Test #67:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
25 0 0 15 0
2 21 6 4 7
1 1 1 29 8
1 34 1 0 4
4 3 2 28 3

output:

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

result:

ok djq dxm tie tie

Test #68:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
10 26 2 0 2
5 9 5 2 19
20 9 6 3 2
17 17 3 2 1
5 2 3 16 14

output:

2
2 0 0 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
21
2 2 2 2 2 2 2 2 2 2 1 0 0 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 -2 2 -2 2 -2 2 -2 2 
2
2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2...

result:

ok djq dxm tie tie

Test #69:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
1 28 0 0 11
39 0 1 0 0
2 5 7 6 20
6 0 0 33 1
3 0 1 3 33

output:

2
2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -2 
0
0 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
37
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 0 0 0 0 0 0 -1 1 -1 1 -...

result:

ok djq dxm tie tie

Test #70:

score: 18
Accepted
time: 0ms
memory: 3716kb

input:

5
33 6 1 0 0
2 23 2 0 13
6 4 0 24 6
0 25 4 1 10
7 2 7 17 7

output:

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

result:

ok djq dxm tie tie

Test #71:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
0 22 1 1 16
11 19 4 2 4
3 6 3 2 26
2 1 7 9 21
22 0 0 18 0

output:

11
2 2 2 2 2 1 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2
2 0 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
42
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -2 2...

result:

ok djq dxm tie tie

Test #72:

score: 18
Accepted
time: 0ms
memory: 3636kb

input:

5
2 0 1 24 13
1 2 1 4 32
27 6 4 1 2
3 2 2 28 5
34 0 0 4 2

output:

46
2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -2 1 1 -2 1 1 
64
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 1 -1 1 -2 1 1 
2
2 0 0 0 0 -1 1 -1 -1 2 -1 -1 -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 
30
2 2 2 2 ...

result:

ok djq dxm tie tie

Test #73:

score: 18
Accepted
time: 0ms
memory: 3684kb

input:

5
0 3 1 1 35
3 12 1 1 23
35 0 3 1 1
9 4 2 17 8
0 28 2 2 8

output:

68
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 1 -1 -1 2 
29
2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 -2 2 -2 2 
2
2 0 0 0 -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 ...

result:

ok djq dxm tie tie

Test #74:

score: 18
Accepted
time: 0ms
memory: 3580kb

input:

5
21 12 3 3 1
15 4 4 13 4
13 17 4 4 2
23 3 3 7 4
3 3 6 3 25

output:

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

result:

ok djq dxm tie tie

Test #75:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
19 10 5 5 1
3 5 4 23 5
1 17 0 1 21
1 22 2 0 15
1 3 0 24 12

output:

2
2 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
22
2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 
24
2 2 2 2 2 2 2 2 2 2 2 2 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 ...

result:

ok djq dxm tie tie

Test #76:

score: 18
Accepted
time: 0ms
memory: 3648kb

input:

5
34 1 1 4 0
9 21 5 4 1
4 20 4 2 10
2 9 5 1 23
8 0 0 32 0

output:

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

result:

ok djq dxm tie tie

Test #77:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
4 4 10 21 1
3 17 2 1 17
0 0 1 30 9
9 20 4 6 1
3 23 2 3 9

output:

11
2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
12
2 2 2 2 2 2 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 -2 2 -2 2 
48
2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 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 
2
2 0 0 0 0 -1 1 -1 ...

result:

ok djq dxm tie tie

Test #78:

score: 18
Accepted
time: 0ms
memory: 3584kb

input:

5
11 2 3 22 2
4 6 9 12 9
5 19 3 5 8
4 9 8 15 4
3 3 7 23 4

output:

2
2 0 0 0 -1 1 -1 1 -2 2 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
16
2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -2 2 -2 1 1 -2 1 1 -2 1 1 
2
2 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 -2 -2 -2 -2 
6
2...

result:

ok djq dxm tie tie

Test #79:

score: 18
Accepted
time: 0ms
memory: 3612kb

input:

5
0 0 0 32 8
1 3 4 15 17
0 15 1 0 24
3 16 4 3 14
2 0 0 29 9

output:

48
2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
44
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 -1 1 -2 1 1 
33
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
9
2 2 2 2 1 0 0 0 0 -1 1 -1 1...

result:

ok djq dxm tie tie

Test #80:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
12 0 1 26 1
9 5 1 20 5
6 0 8 21 5
0 0 2 5 33
0 1 1 6 32

output:

4
2 1 1 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
7
2 2 2 1 0 -1 1 -1 1 -1 1 -1 1 -1 1 -2 2 -2 2 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
19
2 2 2 2 2 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
71
2 2 2 2 2 2 2 2...

result:

ok djq dxm tie tie

Test #81:

score: 18
Accepted
time: 0ms
memory: 3652kb

input:

5
17 6 9 3 5
0 3 0 22 15
29 1 1 9 0
28 6 4 1 1
0 1 0 5 34

output:

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

result:

ok djq dxm tie tie

Test #82:

score: 18
Accepted
time: 0ms
memory: 3660kb

input:

5
13 1 0 25 1
15 22 2 1 0
1 0 1 4 34
28 1 3 7 1
0 0 0 34 6

output:

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

result:

ok djq dxm tie tie

Test #83:

score: 18
Accepted
time: 0ms
memory: 3708kb

input:

5
1 1 1 11 26
3 3 4 15 15
2 0 1 19 18
24 8 2 4 2
0 10 1 0 29

output:

60
2 2 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 1 1 1 1 1 1 1 0 -1 1 -2 1 1 
36
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 
51
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -2 1 1 -2 1 1 
2
2 0 0 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -1...

result:

ok djq dxm tie tie

Test #84:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
2 5 3 2 28
33 0 0 5 2
0 12 0 0 28
4 1 6 5 24
2 2 1 33 2

output:

49
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 0 0 0 -1 1 -1 -1 2 -1 -1 2 -2 2 -2 2 
2
2 -2 2 -2 1 1 -2 1 1 -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 
44
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 ...

result:

ok djq dxm tie tie

Test #85:

score: 18
Accepted
time: 0ms
memory: 3584kb

input:

5
3 32 0 1 4
20 15 1 2 2
24 1 3 4 8
19 16 1 2 2
2 10 3 2 23

output:

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

result:

ok djq dxm tie tie

Test #86:

score: 18
Accepted
time: 0ms
memory: 3632kb

input:

5
18 12 3 6 1
7 19 5 5 4
27 7 3 1 2
18 1 0 21 0
0 2 2 25 11

output:

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

result:

ok djq dxm tie tie

Test #87:

score: 18
Accepted
time: 0ms
memory: 3652kb

input:

5
2 2 4 17 15
7 15 6 7 5
0 23 1 1 15
0 32 0 2 6
28 6 3 2 1

output:

41
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 -2 1 1 -2 1 1 
2
2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 -2 -2 -2 -2 -2 -2 
8
2 2 2 2 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2...

result:

ok djq dxm tie tie

Test #88:

score: 18
Accepted
time: 0ms
memory: 3592kb

input:

5
26 1 10 1 2
4 26 3 3 4
14 19 4 0 3
0 15 1 1 23
15 13 7 4 1

output:

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

result:

ok djq dxm tie tie

Test #89:

score: 18
Accepted
time: 0ms
memory: 3588kb

input:

5
1 4 2 16 17
24 1 2 10 3
3 13 3 1 20
0 9 1 2 28
27 1 5 5 2

output:

44
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 
2
2 0 0 -1 1 -2 2 -2 2 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
22
2 2 2 2 2 2 2 2 2 2 2 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 -2 2 -2 2 
49
...

result:

ok djq dxm tie tie

Test #90:

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

input:

5
0 0 2 15 23
4 35 0 1 0
13 2 2 17 6
0 0 1 33 6
0 28 1 0 11

output:

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

result:

ok djq dxm tie tie

Test #91:

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

input:

5
5 4 5 20 6
4 4 3 15 14
0 18 1 1 20
0 1 1 33 5
30 8 2 0 0

output:

18
2 2 2 2 2 2 1 1 1 1 1 1 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
31
2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 0 0 0 -1 1 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
23
2 2 2 2 2 2 2 2 2 2 2 1 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
42
2 2 2 2 2 ...

result:

ok djq dxm tie tie

Test #92:

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

input:

5
3 2 4 2 29
22 12 1 2 3
5 3 4 24 4
1 1 2 15 21
3 1 1 24 11

output:

52
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 0 -1 1 -1 1 -2 2 -2 2 -2 2 
2
2 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
19
2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -1 1 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
54...

result:

ok djq dxm tie tie

Test #93:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
15 1 2 21 1
4 28 2 3 3
19 18 1 2 0
22 0 0 18 0
7 8 4 4 17

output:

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

result:

ok djq dxm tie tie

Test #94:

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

input:

5
0 0 5 4 31
26 0 0 14 0
1 2 0 0 37
2 2 1 22 13
33 4 3 0 0

output:

66
2 2 2 2 2 2 2 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 1 1 1 0 0 0 0 0 
1
1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
70
2 2 2 2 2 2 2 2 2 2 2 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 -1 2 -2 2 
42
2 2 2 2 2 2 2 2 2...

result:

ok djq dxm tie tie

Test #95:

score: 18
Accepted
time: 0ms
memory: 3716kb

input:

5
19 17 2 1 1
0 26 1 2 11
2 9 1 1 27
12 21 2 1 4
2 17 1 4 16

output:

2
2 0 0 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 
2
2 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 
42
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 -1 1 -1 -1 2 -1 -1 2 -1 -...

result:

ok djq dxm tie tie

Test #96:

score: 18
Accepted
time: 0ms
memory: 3712kb

input:

5
12 2 1 25 0
7 26 1 2 4
12 27 0 0 1
4 35 0 1 0
1 0 1 14 24

output:

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

result:

ok djq dxm tie tie

Test #97:

score: 18
Accepted
time: 0ms
memory: 3648kb

input:

5
2 1 2 3 32
4 17 8 4 7
2 25 3 2 8
1 3 10 21 5
19 14 3 2 2

output:

62
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 -1 1 -2 2 -2 1 1 
2
2 0 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -2 -2 -2 -2 
2
2 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 ...

result:

ok djq dxm tie tie

Test #98:

score: 18
Accepted
time: 0ms
memory: 3596kb

input:

5
35 4 1 0 0
32 0 6 0 2
28 0 4 8 0
18 1 1 15 5
15 19 2 3 1

output:

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

result:

ok djq dxm tie tie

Test #99:

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

input:

5
1 3 7 18 11
2 30 3 3 2
5 0 5 25 5
9 4 3 19 5
10 30 0 0 0

output:

35
2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -2 1 1 
2
2 0 0 0 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2 -2 
25
2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 -2 1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
7
2 2 2 ...

result:

ok djq dxm tie tie

Test #100:

score: 18
Accepted
time: 0ms
memory: 3704kb

input:

5
4 1 4 26 5
0 18 0 0 22
1 2 5 14 18
1 11 4 6 18
2 2 8 13 15

output:

27
2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 -1 1 -2 1 1 -2 1 1 -2 1 1 -2 1 1 
26
2 2 2 2 2 2 2 2 2 2 2 2 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
46
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 -1 1 -1 1 -2 1 1 
29
2 2 2 2 2 2 2 2 2 2...

result:

ok djq dxm tie tie

Subtask #3:

score: 18
Accepted

Test #101:

score: 18
Accepted
time: 64ms
memory: 5536kb

input:

1
0 267849 92997 92489 46665

output:

2
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok djq dxm tie tie

Test #102:

score: 18
Accepted
time: 53ms
memory: 4776kb

input:

5
0 1520 1442 12673 6078
0 5869 5820 54694 15838
0 7166 7347 18837 13923
0 2840 2792 8395 42162
0 42228 42318 143169 64889

output:

23309
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #103:

score: 18
Accepted
time: 61ms
memory: 4308kb

input:

10
0 21189 6905 6620 10210
0 2375 2461 3222 266
0 9996 10113 43297 22437
0 5009 5054 68855 1594
0 464 268 272 1583
0 40071 4496 4287 18546
0 770 807 12133 4319
0 3900 552 522 2500
0 37657 37365 69415 22106
0 4454 740 796 12374

output:

5851
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #104:

score: 18
Accepted
time: 62ms
memory: 3912kb

input:

50
0 135 148 1417 387
0 195 37 40 137
0 2458 2423 2449 10751
0 380 416 2920 43
0 2110 2258 5468 852
0 2884 196 188 336
0 35 35 890 858
0 826 815 6547 2068
0 5287 3150 3070 5544
0 1102 1093 5773 6217
0 87 99 872 822
0 1877 460 412 1288
0 385 379 4451 10659
0 272 290 698 4456
0 209 233 467 1331
0 194 ...

output:

2056
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #105:

score: 18
Accepted
time: 56ms
memory: 3744kb

input:

100
0 10788 831 827 1701
0 1455 632 540 1710
0 996 889 849 2047
0 849 919 1839 4617
0 200 176 269 829
0 2 5 3071 786
0 2291 447 442 6310
0 1693 465 477 842
0 1617 485 478 3291
0 431 445 1236 1160
0 385 396 1295 2784
0 48 42 224 24
0 84 86 126 393
0 4 8 1 132
0 7283 89 111 46
0 14 10 596 402
0 1854 8...

output:

2
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok djq dxm tie tie

Test #106:

score: 18
Accepted
time: 61ms
memory: 3664kb

input:

500
0 3 0 11 68
0 1041 203 224 569
0 55 67 86 235
0 55 75 1156 656
0 52 22 14 25
0 11 21 732 703
0 210 229 387 208
0 196 74 78 356
0 665 146 156 449
0 10 11 112 80
0 2 3 28 36
0 464 17 14 308
0 65 54 292 626
0 4 3 435 94
0 467 16 33 169
0 96 84 714 303
0 28 5 14 11
0 1 2 33 26
0 155 12 20 8
0 46 45 ...

output:

144
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 1 1 1 1 1 1 1 -1 1 -1 1 -1 1 
321
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #107:

score: 18
Accepted
time: 61ms
memory: 3628kb

input:

1000
0 61 7 7 213
0 72 67 160 32
0 571 26 42 94
0 2 4 416 334
0 13 14 421 97
0 5 0 0 53
0 19 15 16 629
0 62 46 134 193
0 81 13 17 12
0 223 75 95 735
0 25 43 31 143
0 88 66 169 238
0 23 17 372 726
0 1 2 30 201
0 42 10 6 23
0 13 4 5 156
0 51 54 299 584
0 1304 234 214 587
0 11 20 36 299
0 6 5 171 142
0...

output:

372
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #108:

score: 18
Accepted
time: 62ms
memory: 3604kb

input:

5000
0 10 5 2 37
0 149 4 1 54
0 2 2 17 10
0 2 3 8 123
0 2 2 3 240
0 36 1 5 18
0 30 23 58 106
0 19 18 18 29
0 7 12 62 30
0 11 0 0 5
0 3 6 15 19
0 2 4 31 33
0 81 7 7 157
0 1 3 89 128
0 24 24 100 179
0 33 30 27 20
0 10 11 21 62
0 29 2 0 43
0 0 1 19 12
0 11 3 61 95
0 3 6 12 1
0 232 26 24 30
0 8 8 171 31...

output:

66
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 
2
2 0 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -...

result:

ok djq dxm tie tie

Test #109:

score: 18
Accepted
time: 65ms
memory: 3664kb

input:

10000
0 9 12 19 21
0 38 2 2 10
0 6 2 8 9
0 2 0 45 54
0 0 0 18 28
0 2 0 0 1
0 0 2 9 29
0 40 17 16 10
0 8 3 14 5
0 12 1 0 20
0 2 2 1 13
0 46 6 1 16
0 4 0 0 24
0 8 6 33 2
0 28 1 0 6
0 0 2 6 0
0 10 10 14 74
0 15 18 14 14
0 58 6 9 28
0 4 7 16 13
0 0 0 0 19
0 33 10 6 9
0 0 1 4 8
0 27 2 1 0
0 8 4 48 19
0 2...

output:

52
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 
2
2 0 0 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
20
2 2 2 2 2 2 2 2 2...

result:

ok djq dxm tie tie

Subtask #4:

score: 18
Accepted

Test #110:

score: 18
Accepted
time: 82ms
memory: 5612kb

input:

1
362285 116716 10597 10402 0

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

result:

ok djq dxm tie tie

Test #111:

score: 18
Accepted
time: 73ms
memory: 4380kb

input:

5
8718 1032 982 13498 0
38238 11897 12134 28479 0
53282 53535 3746 3659 0
89442 53019 28808 28681 0
25516 10066 10010 25258 0

output:

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

result:

ok djq dxm tie tie

Test #112:

score: 18
Accepted
time: 70ms
memory: 4180kb

input:

10
192 14756 1299 1353 0
14442 681 729 5821 0
30011 2047 2036 15906 0
1995 100 86 1961 0
4066 1803 1766 2410 0
48813 14424 11084 10850 0
8759 2112 2028 33919 0
4425 37789 11653 11874 0
206 22726 22398 89044 0
36800 4831 4792 18013 0

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

result:

ok djq dxm tie tie

Test #113:

score: 18
Accepted
time: 77ms
memory: 3864kb

input:

50
178 139 24 22 0
5675 4079 593 641 0
4943 31503 6155 6243 0
1800 1667 443 504 0
136 1113 1072 6780 0
820 206 12 7 0
2113 3185 236 209 0
3015 241 219 23435 0
12142 383 356 428 0
3292 1280 154 143 0
8325 3827 316 327 0
4411 7668 2625 2645 0
75 1277 211 214 0
8088 4262 339 320 0
4557 736 818 2254 0
2...

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

result:

ok djq dxm tie tie

Test #114:

score: 18
Accepted
time: 74ms
memory: 3768kb

input:

100
479 488 476 650 0
445 1059 91 99 0
910 2305 44 52 0
1513 266 256 1896 0
1004 588 232 239 0
1567 197 194 203 0
353 105 131 375 0
8671 178 230 254 0
20 15 21 127 0
13420 2572 776 860 0
727 979 445 444 0
21212 9867 1262 1265 0
2679 209 220 606 0
544 590 552 3920 0
2138 1099 42 46 0
1160 4501 485 49...

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

result:

ok djq dxm tie tie

Test #115:

score: 18
Accepted
time: 74ms
memory: 3748kb

input:

500
97 24 18 55 0
45 31 13 7 0
1799 57 39 208 0
958 590 65 66 0
1308 893 66 62 0
1 34 7 4 0
455 272 6 7 0
207 163 161 292 0
76 59 3 3 0
1778 15 16 223 0
427 230 47 48 0
668 94 95 1745 0
574 103 99 313 0
1014 341 52 42 0
144 23 6 7 0
284 41 33 1054 0
378 323 12 21 0
1 40 8 11 0
674 23 24 89 0
285 261...

output:

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

result:

ok djq dxm tie tie

Test #116:

score: 18
Accepted
time: 68ms
memory: 3672kb

input:

1000
13 33 19 27 0
174 83 90 283 0
25 98 53 44 0
222 85 88 188 0
149 229 1 0 0
167 655 195 165 0
149 60 55 183 0
354 13 12 39 0
555 179 41 47 0
54 19 27 50 0
10 92 93 270 0
73 0 1 53 0
162 0 1 181 0
385 670 96 79 0
43 24 21 201 0
365 156 22 26 0
1 0 0 8 0
584 89 13 7 0
80 21 2 0 0
320 47 4 4 0
527 4...

output:

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

result:

ok djq dxm tie tie

Test #117:

score: 18
Accepted
time: 79ms
memory: 3728kb

input:

5000
1 1 1 0 0
12 39 15 15 0
5 4 2 74 0
0 41 6 4 0
0 100 0 100 0
28 9 5 3 0
23 8 4 169 0
7 11 11 84 0
9 29 5 2 0
0 30 1 2 0
6 11 15 60 0
6 0 1 4 0
0 0 0 4 0
22 47 4 3 0
7 8 8 24 0
1 0 0 0 0
7 2 2 5 0
27 40 0 7 0
193 28 32 111 0
19 4 2 2 0
15 2 4 18 0
1 2 0 0 0
23 172 4 1 0
15 0 3 8 0
7 3 10 9 0
292 ...

output:

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

result:

ok djq dxm tie tie

Test #118:

score: 18
Accepted
time: 81ms
memory: 3684kb

input:

10000
7 43 13 16 0
9 3 6 16 0
31 3 1 0 0
6 22 9 5 0
30 79 1 5 0
66 25 3 12 0
48 47 3 4 0
29 0 0 3 0
5 12 7 3 0
30 1 1 10 0
2 7 3 2 0
5 0 4 0 0
0 0 0 1 0
109 0 0 19 0
1 0 0 27 0
54 8 10 17 0
29 3 2 5 0
2 1 0 10 0
41 6 3 7 0
39 27 4 3 0
23 4 1 0 0
58 1 0 111 0
0 0 1 36 0
7 3 3 1 0
8 5 0 4 0
14 2 1 5 0...

output:

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

result:

ok djq dxm tie tie

Subtask #5:

score: 28
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #119:

score: 28
Accepted
time: 65ms
memory: 5660kb

input:

1
178504 23623 23492 250710 23671

output:

2
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok djq dxm tie tie

Test #120:

score: 28
Accepted
time: 53ms
memory: 4676kb

input:

5
1708 1610 1696 2750 166123
1136 512 256 284 263
771 26427 780 803 6080
14280 14119 14248 78941 154015
25 2605 32 22 10514

output:

329970
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #121:

score: 28
Accepted
time: 61ms
memory: 4012kb

input:

10
2249 40534 2290 2248 39333
20766 22473 5026 4986 4948
10225 14205 5039 5073 5051
5932 5993 5942 50968 22667
944 965 980 40302 3825
7133 7216 7235 31632 38174
2408 18331 2302 2341 19381
15107 1968 44 32 55
9108 1713 1618 2537 1741
199 196 203 5524 838

output:

35882
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 djq dxm tie tie

Test #122:

score: 28
Accepted
time: 69ms
memory: 3784kb

input:

50
141 7592 141 140 532
228 89 15 15 16
2371 5830 32 30 45
2691 5078 1621 1558 1567
1135 1356 533 481 471
2772 479 443 782 439
19 29 16 3251 82
533 11508 495 507 4860
110 38 38 186 36
70 1264 80 78 2870
12315 1212 1218 13156 1296
56 59 52 4171 81
43 40 38 1492 4434
258 778 230 245 330
169 679 187 15...

output:

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

result:

ok djq dxm tie tie

Test #123:

score: 28
Accepted
time: 67ms
memory: 3744kb

input:

100
1668 696 685 1801 712
622 358 385 1400 373
962 11047 904 981 8930
450 1361 408 396 834
8351 2244 465 420 408
434 431 423 1854 1831
352 74 52 45 45
55 75 55 54 103
68 47 40 270 54
583 67 58 268 60
851 847 864 3542 859
653 81 89 74 66
1716 70 76 249 52
5 7 7 749 379
1228 890 135 129 139
14 230 17 ...

output:

2
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok djq dxm tie tie

Test #124:

score: 28
Accepted
time: 69ms
memory: 3620kb

input:

500
54 58 54 574 135
9 63 7 11 41
221 40 57 333 40
228 67 72 66 67
727 918 53 52 56
557 40 45 2683 61
138 140 115 967 299
11 20 9 43 104
321 825 16 18 25
24 0 0 15 0
251 690 15 16 15
258 55 48 460 58
32 1 1 28 5
51 12 11 97 13
176 403 47 65 73
39 33 38 65 1080
537 245 3 8 9
249 42 44 135 41
11 97 20...

output:

678
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 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 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok djq dxm tie tie

Test #125:

score: 28
Accepted
time: 64ms
memory: 3732kb

input:

1000
2 340 1 1 256
109 93 116 931 591
16 0 0 20 0
216 11 14 147 11
23 21 26 302 134
5 5 8 16 197
169 122 6 3 6
1 44 4 2 20
4 3 1 6 1
5 148 6 5 138
32 73 28 22 43
43 212 32 23 21
1 3 2 58 11
2 31 2 1 34
40 55 37 230 21
474 22 12 323 12
784 106 87 307 101
138 1 4 92 0
214 51 7 10 10
28 174 12 8 8
4 36...

output:

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

result:

ok djq dxm tie tie

Test #126:

score: 28
Accepted
time: 67ms
memory: 3720kb

input:

5000
1 8 1 1 6
1 29 3 2 25
23 36 6 7 11
8 48 7 6 11
41 58 0 0 0
0 2 3 34 5
1 1 1 12 53
75 9 10 53 14
2 1 0 1 22
1 0 3 31 14
2 32 2 5 24
1 13 3 2 7
4 1 3 14 1
30 263 16 10 10
0 6 2 1 17
8 0 1 155 3
1 16 1 3 8
56 51 28 37 24
5 146 9 7 26
0 0 1 0 4
25 0 0 60 0
2 1 0 2 2
1 0 2 52 8
14 17 12 38 35
0 0 1 ...

output:

3
2 1 0 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 
21
2 2 2 2 2 2 2 2 2 2 1 0 0 0 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -2 2 
2
2 0 0 0 0 0 0 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -1 -1 2 -...

result:

ok djq dxm tie tie

Test #127:

score: 28
Accepted
time: 75ms
memory: 3676kb

input:

10000
0 0 0 4 1
0 0 0 5 18
0 27 0 0 0
40 15 9 70 8
1 0 4 4 8
0 0 0 4 0
0 0 0 10 36
72 1 2 11 1
12 15 6 4 3
2 9 3 2 19
10 0 3 0 0
4 25 3 2 19
8 2 1 39 1
33 9 4 2 2
35 20 1 0 0
2 29 2 4 11
0 1 0 7 2
0 0 0 10 3
27 170 7 10 17
26 9 0 3 1
1 0 1 44 23
3 1 2 5 0
8 29 1 0 0
43 25 2 9 3
0 2 2 1 0
6 1 2 8 1
8...

output:

6
2 1 1 1 1 
41
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 
-1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
2
2 0 0 0 0 0 0 0 0 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 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 2 -2 1 1 -2 1 1 -2 1 1...

result:

ok djq dxm tie tie

Extra Test:

score: 0
Extra Test Passed