QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73686#2617. Browsing the CollectionDualRE 1343ms12244kbC++2.1kb2023-01-27 16:18:332023-01-27 16:18:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-27 16:18:35]
  • 评测
  • 测评结果:RE
  • 用时:1343ms
  • 内存:12244kb
  • [2023-01-27 16:18:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5,M = 6,S = 1 << 5,E = 1e6 + 5;
int n,m,a[N][M];
int Id[N][S],tot;
int fir[N * S],nxt[E],to[E],w[E],ect = 0;
inline void addedge(int u1,int v1)
{
	nxt[++ect] = fir[u1];fir[u1] = ect;to[ect] = v1;
}
int dis[N * S];
bool ton[N];
inline void Doit(int st,int S)
{
	for(int i = (st + 1) % n;i != st;i = (i + 1) % n)
	{
		int flag = 1;
		for(int j = 0;j < m;j++)
			if((S >> j & 1) && a[st][j] != a[i][j])
				flag = 0;
		if(flag) { addedge(Id[st][S],Id[i][S]);break;}
	}
	for(int i = (st - 1 + n) % n;i != st;i = (i + n - 1) % n)
	{
		int flag = 1;
		for(int j = 0;j < m;j++)
			if((S >> j & 1) && a[st][j] != a[i][j])
				flag = 0;
		if(flag) { addedge(Id[st][S],Id[i][S]);break;}
	}
	for(int k = 0;k < m;k++)
		if((S >> k & 1) == 0)
		{
			memset(ton,0,sizeof ton);
			addedge(Id[st][S],Id[st][S ^ (1 << k)]);
			ton[a[st][k]] = 1;
			for(int i = (st + 1) % n;i != st;i = (i + 1) % n)
			{
				int flag = 1;
				for(int j = 0;j < m;j++)
					if((S >> j & 1) && (a[i][j] != a[st][j]))
						flag = 0;
				if(ton[a[i][k]]) flag = 0;
				if(flag)
				{
					ton[a[i][k]] = true;
					addedge(Id[st][S],Id[i][S ^ (1 << k)]);
				}
			}
		}	
	for(int k = 0;k < m;k++)
		if((S >> k & 1))
			addedge(Id[st][S],Id[st][S ^ (1 << k)]);
}
inline void bfs(int S)
{
	for(int i = 1;i <= tot;i++)
		dis[i] = 1e9;
	queue<int>Q;Q.push(S);dis[S] = 0;
	while(!Q.empty())
	{
		int x = Q.front();Q.pop();
		for(int i = fir[x],y;y = to[i],i;i = nxt[i])
			if(dis[y] > dis[x] + 1)
				dis[y] = dis[x] + 1,Q.push(y);
	}
}
int main()
{
	cin >> n >> m;
	for(int i = 0;i < n;i++)
		for(int j = 0;j < m;j++)
			cin >> a[i][j];
	int all = 1 << m;
	for(int i = 0;i < n;i++)
		for(int S = 0;S < all;S++)
			Id[i][S] = ++tot;
	for(int i = 0;i < n;i++)
		for(int j = 0;j < all;j++)
			Doit(i,j);
	for(int i = 0;i < n;i++)
	{
		bfs(Id[i][0]);
		for(int j = 0;j < n;j++)
		{
			int ans = 1e9;
			for(int k = 0;k < all;k++)
				ans = min(ans,dis[Id[j][k]]);
			cout << ans << ' ';
		}
		cout << endl;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 7460kb

input:

9 3
5 3 7
5 3 4
5 3 7
5 3 2
5 3 4
5 3 7
2 3 7
5 3 7
2 3 7

output:

0 1 2 1 2 3 1 2 1 
1 0 1 1 2 2 1 3 2 
2 1 0 1 1 2 1 3 2 
3 2 1 0 1 1 1 3 2 
3 2 2 1 0 1 1 3 2 
3 1 2 1 1 0 1 2 2 
2 1 3 1 2 1 0 1 2 
2 1 3 1 2 2 1 0 1 
1 1 3 1 2 3 2 1 0 

result:

ok 81 numbers

Test #2:

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

input:

2 2
2 2
1 1

output:

0 1 
1 0 

result:

ok 4 number(s): "0 1 1 0"

Test #3:

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

input:

2 5
2 1 1 2 1
1 2 1 2 1

output:

0 1 
1 0 

result:

ok 4 number(s): "0 1 1 0"

Test #4:

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

input:

4 1
4
2
3
2

output:

0 1 1 1 
1 0 1 2 
1 1 0 1 
1 2 1 0 

result:

ok 16 numbers

Test #5:

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

input:

4 5
2 3 4 4 1
3 1 3 4 2
3 1 2 4 4
2 4 3 3 4

output:

0 1 1 1 
1 0 1 1 
1 1 0 1 
1 1 1 0 

result:

ok 16 numbers

Test #6:

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

input:

4 5
2 3 1 4 2
3 2 4 4 4
4 4 4 3 1
3 3 3 1 3

output:

0 1 1 1 
1 0 1 1 
1 1 0 1 
1 1 1 0 

result:

ok 16 numbers

Test #7:

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

input:

8 5
7 8 3 1 5
3 3 8 4 5
5 1 5 8 5
2 7 4 6 7
6 4 3 5 5
5 3 7 6 2
2 4 2 8 6
5 5 4 4 2

output:

0 1 1 1 1 1 1 1 
1 0 1 1 1 1 1 1 
1 1 0 1 1 1 1 1 
1 1 1 0 1 1 1 1 
1 1 1 1 0 1 1 1 
1 1 1 1 1 0 1 1 
1 1 1 1 1 1 0 1 
1 1 1 1 1 1 1 0 

result:

ok 64 numbers

Test #8:

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

input:

16 2
12 15
4 6
16 10
13 3
2 7
2 13
4 1
14 16
14 6
7 11
7 1
13 11
15 7
10 6
4 13
4 13

output:

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

result:

ok 256 numbers

Test #9:

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

input:

16 5
14 3 2 6 11
9 1 4 3 12
16 14 10 1 5
9 4 13 10 16
3 3 13 11 14
10 2 5 7 15
8 7 3 10 16
1 2 7 7 13
11 6 10 3 3
11 5 15 2 9
16 7 14 12 8
1 13 10 2 9
5 11 13 4 3
5 12 8 16 1
15 1 5 11 13
3 11 15 16 16

output:

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

result:

ok 256 numbers

Test #10:

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

input:

26 3
3 16 24
12 6 26
3 6 19
25 11 12
5 22 26
17 1 20
16 11 11
11 23 12
7 17 10
12 9 8
22 19 25
21 17 21
3 25 20
16 4 2
25 25 17
23 8 12
24 4 12
24 14 12
16 6 18
19 10 1
16 6 14
16 26 12
11 6 24
25 7 6
16 1 23
4 2 14

output:

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

result:

ok 676 numbers

Test #11:

score: 0
Accepted
time: 5ms
memory: 7512kb

input:

32 5
4 30 20 26 8
29 18 22 5 14
20 22 31 31 28
12 22 27 12 4
13 7 14 32 16
6 29 20 21 25
22 21 21 20 24
4 14 18 4 28
4 9 9 29 11
11 5 11 20 30
19 27 21 6 7
3 11 2 2 12
24 17 18 30 29
13 8 20 28 26
9 17 2 21 3
32 23 31 11 23
16 28 20 2 5
30 30 11 29 6
15 21 30 17 32
15 18 13 19 25
24 17 26 18 4
23 21...

output:

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

result:

ok 1024 numbers

Test #12:

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

input:

34 2
26 17
32 10
13 8
14 11
17 30
9 32
31 28
20 23
5 25
34 2
32 22
6 7
8 32
17 11
7 5
33 10
6 19
24 5
28 20
27 8
3 25
20 26
3 6
26 25
30 8
23 19
23 27
12 13
13 17
18 34
8 11
8 24
25 22
24 21

output:

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

result:

ok 1156 numbers

Test #13:

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

input:

64 5
4 16 39 57 15
38 19 6 30 35
24 21 29 50 34
7 18 44 10 24
48 8 51 46 48
38 7 7 6 13
5 29 14 6 44
42 57 49 22 38
53 24 29 42 46
37 34 54 44 55
18 59 38 55 13
46 61 61 53 35
30 54 47 25 51
15 13 47 63 48
34 12 30 3 37
22 43 47 3 61
39 6 62 41 26
30 26 2 14 48
1 3 9 43 44
47 40 53 18 31
19 26 41 42...

output:

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

result:

ok 4096 numbers

Test #14:

score: 0
Accepted
time: 7ms
memory: 7464kb

input:

100 3
75 52 18
93 63 78
21 36 95
39 3 64
79 91 97
39 30 41
3 86 24
97 70 70
98 95 12
93 29 51
4 84 49
48 36 5
34 89 86
6 83 21
8 89 14
64 87 57
86 72 69
72 86 56
5 32 54
9 66 12
99 86 14
11 60 56
96 4 71
59 32 46
32 74 98
89 16 37
61 44 76
55 32 1
41 41 63
39 59 73
84 7 87
56 64 81
44 94 41
72 73 12...

output:

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

result:

ok 10000 numbers

Test #15:

score: 0
Accepted
time: 42ms
memory: 7592kb

input:

128 5
122 18 15 41 30
78 109 50 118 101
34 110 71 93 99
98 30 54 126 13
91 99 108 58 97
27 38 75 54 33
47 82 25 25 82
97 23 73 58 117
50 90 92 71 121
39 121 111 73 94
53 8 119 89 80
51 6 40 86 8
90 93 80 35 40
55 30 29 9 114
78 104 61 22 87
83 55 41 55 31
31 66 24 15 8
28 79 38 6 29
57 95 124 104 3
...

output:

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

result:

ok 16384 numbers

Test #16:

score: 0
Accepted
time: 105ms
memory: 7576kb

input:

244 4
190 106 2 214
40 220 21 86
217 147 210 137
244 130 202 68
201 166 70 154
101 148 71 180
137 46 182 62
217 209 81 163
6 101 58 110
234 67 139 212
127 34 147 193
192 235 235 135
17 185 124 132
159 153 13 222
173 224 12 138
236 15 118 33
147 84 224 137
17 114 149 69
53 45 207 24
179 41 202 155
67...

output:

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

result:

ok 59536 numbers

Test #17:

score: 0
Accepted
time: 214ms
memory: 7564kb

input:

256 5
197 131 211 151 128
133 74 92 247 210
81 173 69 34 33
213 153 59 17 54
95 193 174 114 210
10 154 196 59 95
107 101 91 211 149
74 68 84 179 120
191 54 173 3 33
26 218 211 90 69
229 236 137 153 183
250 75 60 18 42
157 249 173 55 142
216 29 111 254 106
76 192 2 108 124
105 33 12 55 64
182 84 91 9...

output:

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

result:

ok 65536 numbers

Test #18:

score: 0
Accepted
time: 117ms
memory: 7608kb

input:

297 3
294 106 225
285 214 198
37 160 58
130 53 190
195 103 224
202 234 19
241 105 214
227 289 93
253 79 146
292 48 163
168 116 55
47 8 244
215 240 285
74 200 70
156 114 276
59 157 134
85 84 272
289 91 283
263 108 244
291 22 172
208 102 239
182 13 114
84 9 220
55 83 297
164 199 11
124 2 87
65 43 269
...

output:

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

result:

ok 88209 numbers

Test #19:

score: 0
Accepted
time: 1196ms
memory: 11188kb

input:

500 5
476 371 300 184 275
302 264 130 67 432
301 54 107 319 223
268 93 476 39 401
166 401 342 165 479
270 277 148 65 306
176 20 212 476 476
56 308 41 224 62
115 421 231 477 331
147 323 442 19 407
285 388 417 158 99
388 440 293 453 75
222 64 139 49 7
54 85 304 142 171
487 276 14 274 106
11 271 203 32...

output:

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

Test #20:

score: 0
Accepted
time: 1093ms
memory: 11856kb

input:

500 5
399 86 156 285 15
372 30 448 8 255
108 51 324 477 58
308 273 278 202 107
426 70 272 207 382
225 500 292 309 182
440 286 235 437 373
214 375 155 177 463
372 153 36 128 336
23 79 161 97 353
70 139 154 465 34
89 68 395 302 15
496 174 174 229 29
270 127 415 92 89
347 206 105 490 397
154 283 453 3 ...

output:

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

Test #21:

score: 0
Accepted
time: 1044ms
memory: 10548kb

input:

500 5
342 382 243 44 16
263 277 158 364 366
91 88 130 325 391
445 191 116 152 16
140 119 143 25 252
165 32 386 205 267
283 184 288 88 184
230 253 247 223 452
318 141 152 40 68
358 291 313 327 384
114 87 243 74 4
60 301 350 9 214
303 422 267 364 200
287 338 439 371 431
221 207 364 394 317
357 10 89 1...

output:

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

Test #22:

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

input:

500 5
406 17 369 227 383
378 200 300 167 170
11 89 478 170 479
341 374 293 409 121
362 355 184 144 173
380 24 259 408 178
382 442 309 280 69
498 168 44 198 490
393 261 296 340 197
341 474 91 490 368
96 228 110 436 72
316 230 413 32 121
366 71 268 187 42
399 67 463 128 1
199 69 409 409 333
261 364 28...

output:

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

Test #23:

score: 0
Accepted
time: 847ms
memory: 11664kb

input:

500 5
441 212 155 469 25
215 434 175 2 333
56 455 394 79 402
385 57 436 50 124
96 277 169 287 259
213 392 134 58 45
376 455 101 139 149
309 353 52 129 253
55 455 399 331 149
397 49 101 139 215
36 87 286 353 140
308 250 394 274 292
96 55 89 277 220
103 215 40 480 371
270 185 190 273 427
84 436 465 18...

output:

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

result:

ok 250000 numbers

Test #24:

score: 0
Accepted
time: 773ms
memory: 11808kb

input:

500 5
44 198 349 481 393
312 305 16 380 239
391 210 82 72 126
1 351 466 163 71
437 181 178 104 437
203 349 386 350 73
101 286 354 387 395
236 319 495 199 63
403 491 354 417 493
281 195 82 238 307
412 73 214 481 393
405 208 4 112 435
9 198 354 136 63
445 215 326 14 437
267 208 231 455 150
31 246 87 2...

output:

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

result:

ok 250000 numbers

Test #25:

score: 0
Accepted
time: 772ms
memory: 9708kb

input:

500 5
165 146 232 478 317
366 69 411 23 290
457 309 457 478 78
2 228 384 231 158
444 216 292 95 354
322 387 386 21 371
341 468 234 490 439
210 1 331 23 32
464 397 161 147 160
434 228 331 258 236
136 487 457 140 2
434 365 348 365 160
341 428 311 147 167
426 69 46 206 310
154 428 14 370 236
165 116 45...

output:

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

result:

ok 250000 numbers

Test #26:

score: 0
Accepted
time: 805ms
memory: 11804kb

input:

500 5
388 287 233 175 313
462 340 182 175 257
243 262 191 202 78
388 280 191 202 82
243 17 181 224 158
199 107 76 318 257
199 107 389 175 244
199 460 445 318 276
121 483 219 224 376
373 280 187 95 257
121 133 445 152 218
134 439 191 175 158
440 280 191 202 196
223 279 191 149 257
199 107 187 175 26
...

output:

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

result:

ok 250000 numbers

Test #27:

score: 0
Accepted
time: 866ms
memory: 11800kb

input:

500 5
262 287 355 51 171
86 55 127 51 104
199 287 174 419 104
262 240 75 41 452
39 307 164 41 437
262 307 174 470 104
262 465 399 470 437
256 287 355 51 68
231 52 174 50 11
359 464 399 51 104
256 55 81 41 342
256 55 154 51 104
231 55 127 470 45
160 55 174 470 11
256 55 174 270 437
256 287 174 41 11
...

output:

0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 2 1 1 1 2 2 1 1 1 1 1 2 1 2 1 1 1 2 2 1 2 1 1 2 2 1 1 1 1 2 2 2 2 2 2 2 1 2 2 1 1 2 2 1 1 2 2 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 1 2 2 2 2 2 2 1 2 2 1 2 2 1 2 1 1 2 2 2 2 2 2 2 1 3 2 3 2 2 2 2 2 2 2 2 2 2 3 2 2 2 3 2 2 2 3 2 2 2 2 3 2 3 1 2 2 1 2 2 1 3 1 ...

result:

ok 250000 numbers

Test #28:

score: 0
Accepted
time: 846ms
memory: 7672kb

input:

500 5
328 350 179 118 475
330 14 495 316 146
76 350 96 316 70
200 350 179 174 63
76 314 495 272 63
330 314 96 50 475
330 350 179 272 351
301 350 1 272 63
330 350 495 323 351
301 350 1 316 475
200 350 179 316 283
330 350 179 316 475
330 350 197 316 146
330 23 495 272 351
330 350 179 50 146
200 44 495...

output:

0 1 1 1 1 1 1 1 1 2 1 3 1 1 2 1 2 2 1 1 2 2 1 1 2 3 3 1 2 2 3 2 3 2 3 2 2 2 2 3 1 3 1 2 2 2 2 3 3 4 3 1 3 2 2 2 2 2 2 2 2 3 2 1 2 2 3 1 1 1 2 2 1 3 2 1 2 1 3 3 4 2 4 3 3 2 3 2 3 3 1 3 3 3 2 3 2 3 3 3 2 3 3 3 2 3 4 3 3 4 4 3 4 3 3 2 2 3 3 2 3 2 3 1 3 3 1 3 2 2 2 3 2 2 2 3 2 3 3 4 4 3 4 2 3 2 2 1 2 3 ...

result:

ok 250000 numbers

Test #29:

score: 0
Accepted
time: 751ms
memory: 7748kb

input:

500 5
179 212 356 214 238
174 212 425 214 238
179 212 356 239 238
276 196 356 214 245
179 212 356 14 238
34 93 356 214 238
174 212 356 214 238
179 212 356 214 238
174 212 169 214 238
174 212 356 239 183
179 93 356 214 245
174 93 169 214 238
174 93 356 239 245
174 214 356 214 245
179 212 425 214 238
...

output:

0 1 1 1 1 1 2 3 1 1 2 2 2 1 2 2 2 3 1 1 2 3 2 3 3 4 3 2 2 4 4 4 2 4 2 4 2 1 1 3 2 2 1 2 3 3 2 3 5 4 3 3 1 2 3 3 2 2 2 2 3 4 4 4 4 3 4 2 1 3 2 2 4 2 3 3 1 3 3 4 3 2 4 4 4 3 3 3 3 5 3 5 4 4 2 4 4 4 2 3 4 2 4 5 4 4 3 4 2 4 4 4 3 4 4 2 4 4 2 3 3 4 5 4 4 2 2 3 4 4 5 4 4 2 5 4 4 2 4 4 5 5 5 4 3 5 4 5 4 2 ...

result:

ok 250000 numbers

Test #30:

score: 0
Accepted
time: 642ms
memory: 11780kb

input:

500 5
68 11 60 249 375
68 11 60 396 375
68 11 60 468 375
68 372 60 396 375
68 11 153 396 375
68 11 60 468 375
68 11 60 396 375
68 11 60 468 375
432 372 60 396 477
68 11 60 396 402
68 11 60 396 375
68 11 60 396 375
68 11 60 396 375
68 11 60 396 375
68 372 364 396 375
68 11 60 396 375
68 372 153 249 3...

output:

0 1 1 1 1 2 4 3 1 1 3 4 4 3 1 3 2 2 3 2 5 5 4 4 2 4 4 5 6 7 6 4 6 7 6 4 6 4 4 3 1 3 3 3 5 6 6 5 3 5 4 6 6 5 3 5 6 7 5 4 5 4 6 4 2 4 5 4 6 5 4 6 6 5 2 5 4 4 4 6 4 5 2 5 6 6 5 4 2 4 4 4 3 1 3 4 3 5 6 4 3 4 3 5 4 2 4 2 1 3 3 5 4 5 3 5 5 4 2 4 4 5 5 3 5 4 4 4 5 2 5 4 5 2 3 4 3 3 5 6 5 2 5 6 6 4 6 4 5 4 ...

result:

ok 250000 numbers

Test #31:

score: 0
Accepted
time: 494ms
memory: 7684kb

input:

500 5
61 310 443 489 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 343
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 67 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310 443 270 80
61 310...

output:

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

result:

ok 250000 numbers

Test #32:

score: 0
Accepted
time: 321ms
memory: 7672kb

input:

500 5
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 233 369 485
441 40 23...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...

result:

ok 250000 numbers

Test #33:

score: 0
Accepted
time: 282ms
memory: 9672kb

input:

500 5
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 79 234 85
485 1 ...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...

result:

ok 250000 numbers

Test #34:

score: 0
Accepted
time: 291ms
memory: 9528kb

input:

500 5
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 402 75 226
259 293 4...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...

result:

ok 250000 numbers

Test #35:

score: 0
Accepted
time: 317ms
memory: 7668kb

input:

500 5
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 489 371 295
434 395 129 371 295
434 395 489 37...

output:

0 1 2 3 4 5 6 7 7 6 5 4 3 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ...

result:

ok 250000 numbers

Test #36:

score: 0
Accepted
time: 309ms
memory: 7680kb

input:

500 5
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 438 110
312 110 337 43...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 10...

result:

ok 250000 numbers

Test #37:

score: 0
Accepted
time: 423ms
memory: 7608kb

input:

500 5
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446 44 286 153
93 446...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 12 11 10 9 8 7 6 5 4 3 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 8...

result:

ok 250000 numbers

Test #38:

score: 0
Accepted
time: 519ms
memory: 9680kb

input:

500 5
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41 265 66 122
198 41...

output:

0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 1 3 4 5 6 7 7 6 5 4 3 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1 3 4 3 1 3 4 5 6 5 4 ...

result:

ok 250000 numbers

Test #39:

score: 0
Accepted
time: 818ms
memory: 7644kb

input:

500 5
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 252 38 96 129
236 25...

output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1 3 1 3 3 1 3 3 1 3 3 1 3 4 4 3 1 3 4 5 4 3 1 1 3 4 3 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1 3 4 5 6 7 8 9 9...

result:

ok 250000 numbers

Test #40:

score: 0
Accepted
time: 1343ms
memory: 12244kb

input:

500 5
391 229 172 423 130
391 229 446 423 130
391 229 172 423 130
391 229 172 423 130
391 229 172 423 130
391 229 172 423 99
391 379 172 423 130
391 229 172 423 130
391 229 172 423 130
391 229 172 423 130
391 118 172 423 130
391 229 172 423 130
391 229 172 423 130
391 229 172 423 130
391 229 172 423...

output:

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

result:

ok 250000 numbers

Test #41:

score: -100
Runtime Error

input:

500 5
357 490 321 94 30
357 490 321 94 55
357 490 321 98 30
499 490 321 94 30
357 490 321 94 78
357 490 321 94 30
357 441 304 94 30
357 196 321 94 30
357 490 321 94 423
357 490 321 94 30
391 490 321 325 30
357 490 321 94 30
357 490 321 86 30
357 490 321 94 30
357 490 321 94 30
357 490 321 94 30
357 ...

output:


result: