QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21636#2848. 城市地铁规划ha114514ha#AC ✓28ms79496kbC++204.1kb2022-03-07 17:22:172022-05-08 03:45:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 03:45:20]
  • 评测
  • 测评结果:AC
  • 用时:28ms
  • 内存:79496kb
  • [2022-03-07 17:22:17]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#include<ctime>
#include<random>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define bc(x) __builtin_popcount(x)
#define re register
#define il inline
#define pii pair<int,int>
#define pil pair<int,long long>
#define pll pair<long long,long long>
#define mem0(x) memset(x,0,sizeof(x))
#define mem0x3f(x) memset(x,0x3f,sizeof(x))
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
// #pragma GCC optimize(3)
#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
namespace IO_BUFF{
	mt19937 rnd(time(0)^(ll)(new char));
	int rend(int x){
		return rnd()%x+1;
	}
	void rendom_shuffle(int *a,int len){
		shuffle(a+1,a+len+1,rnd);
	}
	const int BS=(1<<24)+5;char Buffer[BS],*HD,*TL;
	inline int gc(){
	    if(HD==TL) TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);
	    return (HD==TL)?EOF:*HD++;
	}
	inline int inn(){
	    int x,ch,s=1;while((ch=gc())<'0'||ch>'9')if(ch=='-')s=-1;x=ch^'0';
	    while((ch=gc())>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^'0');return x*s;
	}
	char ssss[19999999],tttt[20];int ssl,ttl;
    inline int print(int x)
    {
        if(x<0)ssss[++ssl]='-',x=(-x);
		if(!x) ssss[++ssl]='0';for(ttl=0;x;x/=10) tttt[++ttl]=char(x%10+'0');
        for(;ttl;ttl--) ssss[++ssl]=tttt[ttl];return ssss[++ssl]='\n';
    }
	inline int Flush(){return fwrite(ssss+1,sizeof(char),ssl,stdout),ssl=0,0;}
	int read(){
		char c=getchar();int x=1;int s=0;
		while(c<'0' || c>'9'){if(c=='-')x=-1;c=getchar();}
		while(c>='0' && c<='9'){
			s=s*10+c-'0';c=getchar();
		}
		return s*x;
	}
}using namespace IO_BUFF;
/*namespace CFConTest{
	const int mod=998244353;
	inline int add(const int &x,const int &y){
		return (x+y>=mod?x+y-mod:x+y);
	}
	inline int del(const int &x,const int &y){
		return (x-y<0?x-y+mod:x-y);
	}
	int ksm(int x,int k){
		int base=1;
		while(k){
			if(k&1)base=1ll*base*x%mod;
			k>>=1;
			x=1ll*x*x%mod;
		}
		return base;
	}
};
using namespace CFConTest;*/
const int N=3050;
const int mod=59393;
int n,m,a[N],h[N];
int f[N][N],g[N]; // in i have chose k
int s[N],c[N];
int st[N],top;
vector<pii> pruefer_decode(vector<int> const& code) {
  //int n = code.size() + 2;
  vector<int> degree(n, 1);
  for (int i : code) degree[i]++;

  set<int> leaves;
  for (int i = 0; i < n; i++)
    if (degree[i] == 1) leaves.insert(i);

  vector<pair<int, int>> edges;
  for (int v : code) {
    int leaf = *leaves.begin();
    leaves.erase(leaves.begin());

    edges.emplace_back(leaf, v);
    if (--degree[v] == 1) leaves.insert(v);
  }
  edges.emplace_back(*leaves.begin(), n - 1);
  return edges;
}
signed main(){
	#ifdef newbiewzs
		freopen("data.in","r",stdin);
	//	freopen("std.out","w",stdout);
	#else
	#endif
	n=read();m=read();
	
//	n=3000;m=0;
	for(int i=0;i<=m;i++){
		a[i]=read();
	}
	for(int i=0;i<=n;i++){
		int pre=1;
		for(int k=0;k<=m;k++){
			h[i]=(h[i]+a[k]*pre)%mod;
			pre=pre*i%mod;
		}
	}
	if(n==1){
		cout<<0<<" "<<h[0]<<'\n';
		return 0;
	}
	if(n==2){
		cout<<1<<" "<<2*h[1]<<'\n';
		cout<<1<<" "<<2;
		return 0;
	}
	memset(f,-10,sizeof(f));
	//f[0][1]=0;
	f[1][1]=h[2]-h[1];
	for(int i=1;i<=n-2;i++){
		for(int j=1;j<=i-1;j++){
			if(f[i-1][j]+h[2]-h[1]>f[i][1]){
				g[i]=j;
			}
			f[i][1]=max(f[i][1],f[i-1][j]+h[2]-h[1]);
		}
		for(int k=1;k<=i;k++){
			if(k>1)f[i][k]=max(f[i][k],f[i-1][k-1]+h[k+1]-h[k]);
		}
	}
	int ans=-1e9;
	int las=0;
	for(int i=1;i<=n-2;i++){
		if(f[n-2][i]>ans){
			las=i;
		}
		ans=max(ans,f[n-2][i]);
	}
	ans+=h[1]*n;
	cout<<n-1<<" "<<ans<<'\n';
//	return 0;
	int u=n-2;
	while(1){
		u=u-las+1;
		st[++top]=las;
		las=g[u];
		u--;
		if(!las)break;
	}
	vi tmp;
	for(int i=1;i<=top;i++){
		for(int k=1;k<=st[i];k++)tmp.pb(i-1);
	}
	auto kel=pruefer_decode(tmp);
	for(auto k:kel){
		cout<<k.fi+1<<" "<<k.se+1<<'\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 14ms
memory: 77172kb

input:

63 7
4 50 14 48 33 13 44 24

output:

62 992106
32 1
1 2
33 2
2 3
34 3
3 4
35 4
4 5
36 5
5 6
37 6
6 7
38 7
7 8
39 8
8 9
40 9
9 10
41 10
10 11
42 11
11 12
43 12
12 13
44 13
13 14
45 14
14 15
46 15
15 16
47 16
16 17
48 17
17 18
49 18
18 19
50 19
19 20
51 20
20 21
52 21
21 22
53 22
22 23
54 23
23 24
55 24
24 25
56 25
25 26
57 26
26 27
58 2...

result:

ok 

Test #2:

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

input:

208 7
23 28 14 16 46 28 26 28

output:

207 3317121
104 1
105 1
1 2
106 2
2 3
107 3
3 4
108 4
4 5
109 5
5 6
110 6
6 7
111 7
7 8
112 8
8 9
113 9
9 10
114 10
10 11
115 11
11 12
116 12
12 13
117 13
13 14
118 14
14 15
119 15
15 16
120 16
16 17
121 17
17 18
122 18
18 19
123 19
19 20
124 20
20 21
125 21
21 22
126 22
22 23
127 23
23 24
128 24
24...

result:

ok 

Test #3:

score: 0
Accepted
time: 16ms
memory: 76724kb

input:

2928 3
27 20 7 29

output:

2927 13889888
267 1
268 1
269 1
270 1
271 1
272 1
273 1
274 1
275 1
276 1
277 1
1 2
278 2
279 2
280 2
281 2
282 2
283 2
284 2
285 2
286 2
287 2
2 3
288 3
289 3
290 3
291 3
292 3
293 3
294 3
295 3
296 3
297 3
3 4
298 4
299 4
300 4
301 4
302 4
303 4
304 4
305 4
306 4
307 4
4 5
308 5
309 5
310 5
311 5
...

result:

ok 

Test #4:

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

input:

320 3
46 42 15 15

output:

319 1260206
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
1 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
2 3
47 3
48 3
49 3
50 3
51 3
52 3
53 3
54 3
55 3
56 3
57 3
58 3
59 3
3 4
60 4
61 4
62 4
63 4
64 4
65 4
66 4
67 4
68 4
69 4
70 4
71 4
72 4
4 5
73 5
74 5
75 5
76 5
77 5
78...

result:

ok 

Test #5:

score: 0
Accepted
time: 17ms
memory: 77744kb

input:

380 5
41 27 8 3 31 0

output:

379 3140470
77 1
78 1
79 1
1 2
80 2
81 2
82 2
83 2
2 3
84 3
85 3
86 3
87 3
3 4
88 4
89 4
90 4
91 4
4 5
92 5
93 5
94 5
95 5
5 6
96 6
97 6
98 6
99 6
6 7
100 7
101 7
102 7
103 7
7 8
104 8
105 8
106 8
107 8
8 9
108 9
109 9
110 9
111 9
9 10
112 10
113 10
114 10
115 10
10 11
116 11
117 11
118 11
119 11
11...

result:

ok 

Test #6:

score: 0
Accepted
time: 11ms
memory: 77944kb

input:

365 5
35 20 24 29 3 25

output:

364 3508667
122 1
123 1
124 1
1 2
125 2
126 2
2 3
127 3
128 3
3 4
129 4
130 4
4 5
131 5
132 5
5 6
133 6
134 6
6 7
135 7
136 7
7 8
137 8
138 8
8 9
139 9
140 9
9 10
141 10
142 10
10 11
143 11
144 11
11 12
145 12
146 12
12 13
147 13
148 13
13 14
149 14
150 14
14 15
151 15
152 15
15 16
153 16
154 16
16 ...

result:

ok 

Test #7:

score: 0
Accepted
time: 15ms
memory: 78412kb

input:

318 6
4 44 46 6 37 14 49

output:

317 6799456
159 1
160 1
1 2
161 2
2 3
162 3
3 4
163 4
4 5
164 5
5 6
165 6
6 7
166 7
7 8
167 8
8 9
168 9
9 10
169 10
10 11
170 11
11 12
171 12
12 13
172 13
13 14
173 14
14 15
174 15
15 16
175 16
16 17
176 17
17 18
177 18
18 19
178 19
19 20
179 20
20 21
180 21
21 22
181 22
22 23
182 23
23 24
183 24
24...

result:

ok 

Test #8:

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

input:

416 6
30 23 4 16 45 32 19

output:

415 5383994
208 1
209 1
1 2
210 2
2 3
211 3
3 4
212 4
4 5
213 5
5 6
214 6
6 7
215 7
7 8
216 8
8 9
217 9
9 10
218 10
10 11
219 11
11 12
220 12
12 13
221 13
13 14
222 14
14 15
223 15
15 16
224 16
16 17
225 17
17 18
226 18
18 19
227 19
19 20
228 20
20 21
229 21
21 22
230 22
22 23
231 23
23 24
232 24
24...

result:

ok 

Test #9:

score: 0
Accepted
time: 24ms
memory: 76668kb

input:

572 5
15 27 5 18 3 46

output:

571 9396678
191 1
192 1
193 1
1 2
194 2
195 2
2 3
196 3
197 3
3 4
198 4
199 4
4 5
200 5
201 5
5 6
202 6
203 6
6 7
204 7
205 7
7 8
206 8
207 8
8 9
208 9
209 9
9 10
210 10
211 10
10 11
212 11
213 11
11 12
214 12
215 12
12 13
216 13
217 13
13 14
218 14
219 14
14 15
220 15
221 15
15 16
222 16
223 16
16 ...

result:

ok 

Test #10:

score: 0
Accepted
time: 21ms
memory: 77924kb

input:

531 8
20 13 35 27 41 43 36 25 5

output:

530 9024252
178 1
1 2
179 2
180 2
2 3
181 3
182 3
3 4
183 4
184 4
4 5
185 5
186 5
5 6
187 6
188 6
6 7
189 7
190 7
7 8
191 8
192 8
8 9
193 9
194 9
9 10
195 10
196 10
10 11
197 11
198 11
11 12
199 12
200 12
12 13
201 13
202 13
13 14
203 14
204 14
14 15
205 15
206 15
15 16
207 16
208 16
16 17
209 17
21...

result:

ok 

Test #11:

score: 0
Accepted
time: 16ms
memory: 78096kb

input:

487 10
29 29 40 45 5 16 40 47 47 2 14

output:

486 18026623
486 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok 

Test #12:

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

input:

584 7
10 27 29 8 32 43 26 3

output:

583 11437238
292 1
293 1
1 2
294 2
2 3
295 3
3 4
296 4
4 5
297 5
5 6
298 6
6 7
299 7
7 8
300 8
8 9
301 9
9 10
302 10
10 11
303 11
11 12
304 12
12 13
305 13
13 14
306 14
14 15
307 15
15 16
308 16
16 17
309 17
17 18
310 18
18 19
311 19
19 20
312 20
20 21
313 21
21 22
314 22
22 23
315 23
23 24
316 24
2...

result:

ok 

Test #13:

score: 0
Accepted
time: 4ms
memory: 76880kb

input:

59 4
48 16 9 42 21

output:

58 422967
12 1
13 1
14 1
15 1
16 1
1 2
17 2
18 2
19 2
20 2
2 3
21 3
22 3
23 3
24 3
3 4
25 4
26 4
27 4
28 4
4 5
29 5
30 5
31 5
32 5
5 6
33 6
34 6
35 6
36 6
6 7
37 7
38 7
39 7
40 7
7 8
41 8
42 8
43 8
44 8
8 9
45 9
46 9
47 9
48 9
9 10
49 10
50 10
51 10
52 10
10 11
53 11
54 11
55 11
56 11
57 11
58 11
11...

result:

ok 

Test #14:

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

input:

561 3
22 31 17 49

output:

560 3223790
64 1
1 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 2
2 3
73 3
74 3
75 3
76 3
77 3
78 3
79 3
80 3
3 4
81 4
82 4
83 4
84 4
85 4
86 4
87 4
88 4
4 5
89 5
90 5
91 5
92 5
93 5
94 5
95 5
96 5
5 6
97 6
98 6
99 6
100 6
101 6
102 6
103 6
104 6
6 7
105 7
106 7
107 7
108 7
109 7
110 7
111 7
112 7
7 8
11...

result:

ok 

Test #15:

score: 0
Accepted
time: 11ms
memory: 78380kb

input:

629 6
26 31 41 32 13 39 41

output:

628 13149156
315 1
1 2
316 2
2 3
317 3
3 4
318 4
4 5
319 5
5 6
320 6
6 7
321 7
7 8
322 8
8 9
323 9
9 10
324 10
10 11
325 11
11 12
326 12
12 13
327 13
13 14
328 14
14 15
329 15
15 16
330 16
16 17
331 17
17 18
332 18
18 19
333 19
19 20
334 20
20 21
335 21
21 22
336 22
22 23
337 23
23 24
338 24
24 25
3...

result:

ok 

Test #16:

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

input:

616 3
38 48 27 2

output:

615 1394108
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
1 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
2 3
64 3
65 3
66 3
67 3
68 3
69 3
70 3
71 3
72 3
73 3
74 3
75 3
76 3
77 3
78 3
79 3
80 3
81 3
...

result:

ok 

Test #17:

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

input:

744 2
49 45 50

output:

743 1425426
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
1 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
2 3
72 3
73 3
74 3
75 3
76 3
77 3
78 3
79 3
...

result:

ok 

Test #18:

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

input:

629 7
27 18 48 24 37 38 6 3

output:

628 9258317
159 1
1 2
160 2
2 3
161 3
162 3
163 3
3 4
164 4
165 4
166 4
4 5
167 5
168 5
169 5
5 6
170 6
171 6
172 6
6 7
173 7
174 7
175 7
7 8
176 8
177 8
178 8
8 9
179 9
180 9
181 9
9 10
182 10
183 10
184 10
10 11
185 11
186 11
187 11
11 12
188 12
189 12
190 12
12 13
191 13
192 13
193 13
13 14
194 1...

result:

ok 

Test #19:

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

input:

602 8
17 25 14 13 2 16 23 24 44

output:

601 9947756
601 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51...

result:

ok 

Test #20:

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

input:

900 2
9 13 12

output:

899 787522
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
1 2
29 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
...

result:

ok 

Test #21:

score: 0
Accepted
time: 11ms
memory: 78100kb

input:

839 7
12 12 28 33 35 29 14 17

output:

838 24516016
420 1
1 2
421 2
2 3
422 3
3 4
423 4
4 5
424 5
5 6
425 6
6 7
426 7
7 8
427 8
8 9
428 9
9 10
429 10
10 11
430 11
11 12
431 12
12 13
432 13
13 14
433 14
14 15
434 15
15 16
435 16
16 17
436 17
17 18
437 18
18 19
438 19
19 20
439 20
20 21
440 21
21 22
441 22
22 23
442 23
23 24
443 24
24 25
4...

result:

ok 

Test #22:

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

input:

768 7
27 3 40 6 39 9 48 31

output:

767 18960055
384 1
385 1
1 2
386 2
2 3
387 3
3 4
388 4
4 5
389 5
5 6
390 6
6 7
391 7
7 8
392 8
8 9
393 9
9 10
394 10
10 11
395 11
11 12
396 12
12 13
397 13
13 14
398 14
14 15
399 15
15 16
400 16
16 17
401 17
17 18
402 18
18 19
403 19
19 20
404 20
20 21
405 21
21 22
406 22
22 23
407 23
23 24
408 24
2...

result:

ok 

Test #23:

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

input:

783 3
25 19 31 45

output:

782 4263811
88 1
89 1
90 1
91 1
92 1
93 1
94 1
1 2
95 2
96 2
97 2
98 2
99 2
100 2
101 2
102 2
2 3
103 3
104 3
105 3
106 3
107 3
108 3
109 3
110 3
3 4
111 4
112 4
113 4
114 4
115 4
116 4
117 4
118 4
4 5
119 5
120 5
121 5
122 5
123 5
124 5
125 5
126 5
5 6
127 6
128 6
129 6
130 6
131 6
132 6
133 6
134 ...

result:

ok 

Test #24:

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

input:

2 4
24 9 31 45 15

output:

1 248
1 2

result:

ok 

Test #25:

score: 0
Accepted
time: 4ms
memory: 76828kb

input:

792 5
28 40 21 32 44 11

output:

791 6695732
265 1
1 2
266 2
267 2
2 3
268 3
269 3
3 4
270 4
271 4
4 5
272 5
273 5
5 6
274 6
275 6
6 7
276 7
277 7
7 8
278 8
279 8
8 9
280 9
281 9
9 10
282 10
283 10
10 11
284 11
285 11
11 12
286 12
287 12
12 13
288 13
289 13
13 14
290 14
291 14
14 15
292 15
293 15
15 16
294 16
295 16
16 17
296 17
29...

result:

ok 

Test #26:

score: 0
Accepted
time: 11ms
memory: 77680kb

input:

939 5
35 7 31 40 25 28

output:

938 12031060
313 1
314 1
315 1
1 2
316 2
317 2
2 3
318 3
319 3
3 4
320 4
321 4
4 5
322 5
323 5
5 6
324 6
325 6
6 7
326 7
327 7
7 8
328 8
329 8
8 9
330 9
331 9
9 10
332 10
333 10
10 11
334 11
335 11
11 12
336 12
337 12
12 13
338 13
339 13
13 14
340 14
341 14
14 15
342 15
343 15
15 16
344 16
345 16
16...

result:

ok 

Test #27:

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

input:

924 6
30 26 21 8 12 42 26

output:

923 14203740
462 1
463 1
1 2
464 2
2 3
465 3
3 4
466 4
4 5
467 5
5 6
468 6
6 7
469 7
7 8
470 8
8 9
471 9
9 10
472 10
10 11
473 11
11 12
474 12
12 13
475 13
13 14
476 14
14 15
477 15
15 16
478 16
16 17
479 17
17 18
480 18
18 19
481 19
19 20
482 20
20 21
483 21
21 22
484 22
22 23
485 23
23 24
486 24
2...

result:

ok 

Test #28:

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

input:

902 8
8 48 35 25 32 28 21 2 44

output:

901 13244886
901 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok 

Test #29:

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

input:

1021 2
11 16 14

output:

1020 977447
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
1 2
29 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 2
73 2
74 2...

result:

ok 

Test #30:

score: 0
Accepted
time: 4ms
memory: 5692kb

input:

1 9
18 7 32 20 44 12 15 38 14 43

output:

0 18

result:

ok 

Test #31:

score: 0
Accepted
time: 13ms
memory: 78420kb

input:

1060 3
22 35 14 10

output:

1059 3631294
68 1
69 1
1 2
70 2
71 2
72 2
73 2
74 2
75 2
76 2
77 2
78 2
79 2
80 2
81 2
82 2
83 2
84 2
2 3
85 3
86 3
87 3
88 3
89 3
90 3
91 3
92 3
93 3
94 3
95 3
96 3
97 3
98 3
99 3
3 4
100 4
101 4
102 4
103 4
104 4
105 4
106 4
107 4
108 4
109 4
110 4
111 4
112 4
113 4
114 4
4 5
115 5
116 5
117 5
118...

result:

ok 

Test #32:

score: 0
Accepted
time: 13ms
memory: 77992kb

input:

1174 9
43 31 31 48 26 3 12 24 44 15

output:

1173 32850542
587 1
588 1
1 2
589 2
2 3
590 3
3 4
591 4
4 5
592 5
5 6
593 6
6 7
594 7
7 8
595 8
8 9
596 9
9 10
597 10
10 11
598 11
11 12
599 12
12 13
600 13
13 14
601 14
14 15
602 15
15 16
603 16
16 17
604 17
17 18
605 18
18 19
606 19
19 20
607 20
20 21
608 21
21 22
609 22
22 23
610 23
23 24
611 24
...

result:

ok 

Test #33:

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

input:

1132 7
22 41 20 40 1 45 15 41

output:

1131 30428525
566 1
567 1
1 2
568 2
2 3
569 3
3 4
570 4
4 5
571 5
5 6
572 6
6 7
573 7
7 8
574 8
8 9
575 9
9 10
576 10
10 11
577 11
11 12
578 12
12 13
579 13
13 14
580 14
14 15
581 15
15 16
582 16
16 17
583 17
17 18
584 18
18 19
585 19
19 20
586 20
20 21
587 21
21 22
588 22
22 23
589 23
23 24
590 24
...

result:

ok 

Test #34:

score: 0
Accepted
time: 17ms
memory: 77548kb

input:

1144 7
44 11 38 25 10 46 39 14

output:

1143 13475451
230 1
231 1
1 2
232 2
233 2
234 2
235 2
2 3
236 3
237 3
238 3
239 3
3 4
240 4
241 4
242 4
243 4
4 5
244 5
245 5
246 5
247 5
5 6
248 6
249 6
250 6
251 6
6 7
252 7
253 7
254 7
255 7
7 8
256 8
257 8
258 8
259 8
8 9
260 9
261 9
262 9
263 9
9 10
264 10
265 10
266 10
267 10
10 11
268 11
269 ...

result:

ok 

Test #35:

score: 0
Accepted
time: 15ms
memory: 76400kb

input:

143 1
20 39

output:

142 13936
142 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
5...

result:

ok 

Test #36:

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

input:

1193 8
13 14 30 29 27 45 20 50 12

output:

1192 23190532
597 1
1 2
598 2
2 3
599 3
3 4
600 4
4 5
601 5
5 6
602 6
6 7
603 7
7 8
604 8
8 9
605 9
9 10
606 10
10 11
607 11
11 12
608 12
12 13
609 13
13 14
610 14
14 15
611 15
15 16
612 16
16 17
613 17
17 18
614 18
18 19
615 19
19 20
616 20
20 21
617 21
21 22
618 22
22 23
619 23
23 24
620 24
24 25
...

result:

ok 

Test #37:

score: 0
Accepted
time: 20ms
memory: 76728kb

input:

1246 2
36 21 13

output:

1245 1190316
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
1 2
30 2
31 2
32 2
33 2
34 2
35 2
36 2
37 2
38 2
39 2
40 2
41 2
42 2
43 2
44 2
45 2
46 2
47 2
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 2
59 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 2
73 2
74 2
75 2
76 2
77 ...

result:

ok 

Test #38:

score: 0
Accepted
time: 4ms
memory: 77472kb

input:

1282 6
32 30 38 2 32 22 30

output:

1281 19528052
641 1
642 1
1 2
643 2
2 3
644 3
3 4
645 4
4 5
646 5
5 6
647 6
6 7
648 7
7 8
649 8
8 9
650 9
9 10
651 10
10 11
652 11
11 12
653 12
12 13
654 13
13 14
655 14
14 15
656 15
15 16
657 16
16 17
658 17
17 18
659 18
18 19
660 19
19 20
661 20
20 21
662 21
21 22
663 22
22 23
664 23
23 24
665 24
...

result:

ok 

Test #39:

score: 0
Accepted
time: 16ms
memory: 76620kb

input:

1219 5
1 18 2 24 13 41

output:

1218 19108189
407 1
408 1
1 2
409 2
410 2
2 3
411 3
412 3
3 4
413 4
414 4
4 5
415 5
416 5
5 6
417 6
418 6
6 7
419 7
420 7
7 8
421 8
422 8
8 9
423 9
424 9
9 10
425 10
426 10
10 11
427 11
428 11
11 12
429 12
430 12
12 13
431 13
432 13
13 14
433 14
434 14
14 15
435 15
436 15
15 16
437 16
438 16
16 17
4...

result:

ok 

Test #40:

score: 0
Accepted
time: 4ms
memory: 76444kb

input:

1275 7
1 2 2 10 48 11 39 18

output:

1274 12159175
214 1
1 2
215 2
216 2
217 2
218 2
219 2
2 3
220 3
221 3
222 3
223 3
224 3
3 4
225 4
226 4
227 4
228 4
229 4
4 5
230 5
231 5
232 5
233 5
234 5
5 6
235 6
236 6
237 6
238 6
239 6
6 7
240 7
241 7
242 7
243 7
244 7
7 8
245 8
246 8
247 8
248 8
249 8
8 9
250 9
251 9
252 9
253 9
254 9
9 10
255...

result:

ok 

Test #41:

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

input:

1204 6
42 39 31 45 1 45 15

output:

1203 20981458
402 1
403 1
1 2
404 2
405 2
2 3
406 3
407 3
3 4
408 4
409 4
4 5
410 5
411 5
5 6
412 6
413 6
6 7
414 7
415 7
7 8
416 8
417 8
8 9
418 9
419 9
9 10
420 10
421 10
10 11
422 11
423 11
11 12
424 12
425 12
12 13
426 13
427 13
13 14
428 14
429 14
14 15
430 15
431 15
15 16
432 16
433 16
16 17
4...

result:

ok 

Test #42:

score: 0
Accepted
time: 4ms
memory: 77740kb

input:

1433 6
36 45 32 28 2 47 35

output:

1432 27559374
717 1
1 2
718 2
2 3
719 3
3 4
720 4
4 5
721 5
5 6
722 6
6 7
723 7
7 8
724 8
8 9
725 9
9 10
726 10
10 11
727 11
11 12
728 12
12 13
729 13
13 14
730 14
14 15
731 15
15 16
732 16
16 17
733 17
17 18
734 18
18 19
735 19
19 20
736 20
20 21
737 21
21 22
738 22
22 23
739 23
23 24
740 24
24 25
...

result:

ok 

Test #43:

score: 0
Accepted
time: 21ms
memory: 76848kb

input:

1479 4
19 20 14 40 48

output:

1478 13245633
371 1
1 2
372 2
373 2
374 2
2 3
375 3
376 3
377 3
3 4
378 4
379 4
380 4
4 5
381 5
382 5
383 5
5 6
384 6
385 6
386 6
6 7
387 7
388 7
389 7
7 8
390 8
391 8
392 8
8 9
393 9
394 9
395 9
9 10
396 10
397 10
398 10
10 11
399 11
400 11
401 11
11 12
402 12
403 12
404 12
12 13
405 13
406 13
407 ...

result:

ok 

Test #44:

score: 0
Accepted
time: 16ms
memory: 77028kb

input:

1416 5
13 30 1 3 23 37

output:

1415 20881768
473 1
1 2
474 2
475 2
2 3
476 3
477 3
3 4
478 4
479 4
4 5
480 5
481 5
5 6
482 6
483 6
6 7
484 7
485 7
7 8
486 8
487 8
8 9
488 9
489 9
9 10
490 10
491 10
10 11
492 11
493 11
11 12
494 12
495 12
12 13
496 13
497 13
13 14
498 14
499 14
14 15
500 15
501 15
15 16
502 16
503 16
16 17
504 17
...

result:

ok 

Test #45:

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

input:

1366 2
23 7 45

output:

1365 2381528
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
62 1
63 1
64 1
65 1
66 1
67 1
68 1
69 1
70 1
71 1
72 1
73 1
1 2
74 2
75 2
76 2
77 2
78 2
79 2
80 2
81 2
82 2
83 2
84 2
85 2
86 2
87 2
88 2
89 2
90 2
91 2
92 2
93 2
94 2
95 2
96 ...

result:

ok 

Test #46:

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

input:

69 8
9 37 11 27 24 20 26 29 34

output:

68 1060969
24 1
1 2
25 2
26 2
2 3
27 3
28 3
3 4
29 4
30 4
4 5
31 5
32 5
5 6
33 6
34 6
6 7
35 7
36 7
7 8
37 8
38 8
8 9
39 9
40 9
9 10
41 10
42 10
10 11
43 11
44 11
11 12
45 12
46 12
12 13
47 13
48 13
13 14
49 14
50 14
14 15
51 15
52 15
15 16
53 16
54 16
16 17
55 17
56 17
17 18
57 18
58 18
18 19
59 19...

result:

ok 

Test #47:

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

input:

1446 1
31 40

output:

1445 160426
1445 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok 

Test #48:

score: 0
Accepted
time: 20ms
memory: 77704kb

input:

1558 7
1 20 1 18 19 32 23 31

output:

1557 27375776
779 1
780 1
1 2
781 2
2 3
782 3
3 4
783 4
4 5
784 5
5 6
785 6
6 7
786 7
7 8
787 8
8 9
788 9
9 10
789 10
10 11
790 11
11 12
791 12
12 13
792 13
13 14
793 14
14 15
794 15
15 16
795 16
16 17
796 17
17 18
797 18
18 19
798 19
19 20
799 20
20 21
800 21
21 22
801 22
22 23
802 23
23 24
803 24
...

result:

ok 

Test #49:

score: 0
Accepted
time: 21ms
memory: 77128kb

input:

1506 6
13 11 47 4 16 12 23

output:

1505 26313135
503 1
1 2
504 2
505 2
2 3
506 3
507 3
3 4
508 4
509 4
4 5
510 5
511 5
5 6
512 6
513 6
6 7
514 7
515 7
7 8
516 8
517 8
8 9
518 9
519 9
9 10
520 10
521 10
10 11
522 11
523 11
11 12
524 12
525 12
12 13
526 13
527 13
13 14
528 14
529 14
14 15
530 15
531 15
15 16
532 16
533 16
16 17
534 17
...

result:

ok 

Test #50:

score: 0
Accepted
time: 15ms
memory: 78100kb

input:

1502 10
7 28 34 22 15 12 39 22 3 12 1

output:

1501 30324390
751 1
752 1
1 2
753 2
2 3
754 3
3 4
755 4
4 5
756 5
5 6
757 6
6 7
758 7
7 8
759 8
8 9
760 9
9 10
761 10
10 11
762 11
11 12
763 12
12 13
764 13
13 14
765 14
14 15
766 15
15 16
767 16
16 17
768 17
17 18
769 18
18 19
770 19
19 20
771 20
20 21
772 21
21 22
773 22
22 23
774 23
23 24
775 24
...

result:

ok 

Test #51:

score: 0
Accepted
time: 20ms
memory: 77672kb

input:

1554 6
40 26 7 34 32 25 10

output:

1553 17872648
312 1
313 1
1 2
314 2
315 2
316 2
317 2
2 3
318 3
319 3
320 3
321 3
3 4
322 4
323 4
324 4
325 4
4 5
326 5
327 5
328 5
329 5
5 6
330 6
331 6
332 6
333 6
6 7
334 7
335 7
336 7
337 7
7 8
338 8
339 8
340 8
341 8
8 9
342 9
343 9
344 9
345 9
9 10
346 10
347 10
348 10
349 10
10 11
350 11
351 ...

result:

ok 

Test #52:

score: 0
Accepted
time: 20ms
memory: 77740kb

input:

1641 6
4 4 50 32 36 21 45

output:

1640 34686354
821 1
1 2
822 2
2 3
823 3
3 4
824 4
4 5
825 5
5 6
826 6
6 7
827 7
7 8
828 8
8 9
829 9
9 10
830 10
10 11
831 11
11 12
832 12
12 13
833 13
13 14
834 14
14 15
835 15
15 16
836 16
16 17
837 17
17 18
838 18
18 19
839 19
19 20
840 20
20 21
841 21
21 22
842 22
22 23
843 23
23 24
844 24
24 25
...

result:

ok 

Test #53:

score: 0
Accepted
time: 19ms
memory: 77388kb

input:

1704 9
34 25 28 32 46 31 13 5 10 3

output:

1703 33186050
852 1
853 1
1 2
854 2
2 3
855 3
3 4
856 4
4 5
857 5
5 6
858 6
6 7
859 7
7 8
860 8
8 9
861 9
9 10
862 10
10 11
863 11
11 12
864 12
12 13
865 13
13 14
866 14
14 15
867 15
15 16
868 16
16 17
869 17
17 18
870 18
18 19
871 19
19 20
872 20
20 21
873 21
21 22
874 22
22 23
875 23
23 24
876 24
...

result:

ok 

Test #54:

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

input:

1729 10
1 45 47 48 14 11 16 5 44 43 39

output:

1728 28886428
1728 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #55:

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

input:

1674 8
46 26 8 27 50 42 16 8 14

output:

1673 24479277
559 1
1 2
560 2
561 2
2 3
562 3
563 3
3 4
564 4
565 4
4 5
566 5
567 5
5 6
568 6
569 6
6 7
570 7
571 7
7 8
572 8
573 8
8 9
574 9
575 9
9 10
576 10
577 10
10 11
578 11
579 11
11 12
580 12
581 12
12 13
582 13
583 13
13 14
584 14
585 14
14 15
586 15
587 15
15 16
588 16
589 16
16 17
590 17
...

result:

ok 

Test #56:

score: 0
Accepted
time: 28ms
memory: 77796kb

input:

1791 5
2 4 36 30 27 46

output:

1790 33867308
598 1
1 2
599 2
600 2
2 3
601 3
602 3
3 4
603 4
604 4
4 5
605 5
606 5
5 6
607 6
608 6
6 7
609 7
610 7
7 8
611 8
612 8
8 9
613 9
614 9
9 10
615 10
616 10
10 11
617 11
618 11
11 12
619 12
620 12
12 13
621 13
622 13
13 14
623 14
624 14
14 15
625 15
626 15
15 16
627 16
628 16
16 17
629 17
...

result:

ok 

Test #57:

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

input:

219 6
11 26 45 49 10 1 14

output:

218 3123505
56 1
1 2
57 2
58 2
59 2
2 3
60 3
61 3
62 3
3 4
63 4
64 4
65 4
4 5
66 5
67 5
68 5
5 6
69 6
70 6
71 6
6 7
72 7
73 7
74 7
7 8
75 8
76 8
77 8
8 9
78 9
79 9
80 9
9 10
81 10
82 10
83 10
10 11
84 11
85 11
86 11
11 12
87 12
88 12
89 12
12 13
90 13
91 13
92 13
13 14
93 14
94 14
95 14
14 15
96 15
...

result:

ok 

Test #58:

score: 0
Accepted
time: 16ms
memory: 76512kb

input:

1774 3
39 29 31 6

output:

1773 5370690
100 1
101 1
102 1
103 1
104 1
105 1
106 1
107 1
1 2
108 2
109 2
110 2
111 2
112 2
113 2
114 2
115 2
116 2
117 2
118 2
119 2
120 2
121 2
122 2
123 2
124 2
2 3
125 3
126 3
127 3
128 3
129 3
130 3
131 3
132 3
133 3
134 3
135 3
136 3
137 3
138 3
139 3
140 3
141 3
3 4
142 4
143 4
144 4
145 4...

result:

ok 

Test #59:

score: 0
Accepted
time: 11ms
memory: 77440kb

input:

1830 6
25 31 32 37 2 1 43

output:

1829 30462134
915 1
916 1
1 2
917 2
2 3
918 3
3 4
919 4
4 5
920 5
5 6
921 6
6 7
922 7
7 8
923 8
8 9
924 9
9 10
925 10
10 11
926 11
11 12
927 12
12 13
928 13
13 14
929 14
14 15
930 15
15 16
931 16
16 17
932 17
17 18
933 18
18 19
934 19
19 20
935 20
20 21
936 21
21 22
937 22
22 23
938 23
23 24
939 24
...

result:

ok 

Test #60:

score: 0
Accepted
time: 25ms
memory: 77448kb

input:

1886 5
36 33 10 5 16 31

output:

1885 23079262
629 1
630 1
631 1
1 2
632 2
633 2
2 3
634 3
635 3
3 4
636 4
637 4
4 5
638 5
639 5
5 6
640 6
641 6
6 7
642 7
643 7
7 8
644 8
645 8
8 9
646 9
647 9
9 10
648 10
649 10
10 11
650 11
651 11
11 12
652 12
653 12
12 13
654 13
655 13
13 14
656 14
657 14
14 15
658 15
659 15
15 16
660 16
661 16
1...

result:

ok 

Test #61:

score: 0
Accepted
time: 11ms
memory: 78112kb

input:

1907 7
9 37 49 23 34 14 29 24

output:

1906 20753757
954 1
1 2
955 2
2 3
956 3
3 4
957 4
4 5
958 5
5 6
959 6
6 7
960 7
7 8
961 8
8 9
962 9
9 10
963 10
10 11
964 11
11 12
965 12
12 13
966 13
13 14
967 14
14 15
968 15
15 16
969 16
16 17
970 17
17 18
971 18
18 19
972 19
19 20
973 20
20 21
974 21
21 22
975 22
22 23
976 23
23 24
977 24
24 25
...

result:

ok 

Test #62:

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

input:

1840 2
30 14 7

output:

1839 1289412
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
1 2
60 2
61 2
62 2
63 2
64 2
65 2
66 2
67 2
68 2
69 2
70 2
71 2
72 2
73 2
74 2
75 2
76 2
77 2
78 ...

result:

ok 

Test #63:

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

input:

1845 3
46 42 35 46

output:

1844 10496398
206 1
207 1
208 1
209 1
210 1
211 1
212 1
1 2
213 2
214 2
215 2
216 2
217 2
218 2
219 2
220 2
2 3
221 3
222 3
223 3
224 3
225 3
226 3
227 3
228 3
3 4
229 4
230 4
231 4
232 4
233 4
234 4
235 4
236 4
4 5
237 5
238 5
239 5
240 5
241 5
242 5
243 5
244 5
5 6
245 6
246 6
247 6
248 6
249 6
25...

result:

ok 

Test #64:

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

input:

2029 2
41 7 2

output:

2028 808537
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1
62 1
63 1
64 1
65 1
66 1
67 1
68 1
69 1
70 ...

result:

ok 

Test #65:

score: 0
Accepted
time: 25ms
memory: 77148kb

input:

2084 7
40 34 44 27 31 24 50 14

output:

2083 37527190
695 1
696 1
697 1
1 2
698 2
699 2
2 3
700 3
701 3
3 4
702 4
703 4
4 5
704 5
705 5
5 6
706 6
707 6
6 7
708 7
709 7
7 8
710 8
711 8
8 9
712 9
713 9
9 10
714 10
715 10
10 11
716 11
717 11
11 12
718 12
719 12
12 13
720 13
721 13
13 14
722 14
723 14
14 15
724 15
725 15
15 16
726 16
727 16
1...

result:

ok 

Test #66:

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

input:

2002 9
9 8 5 42 1 3 24 27 42 41

output:

2001 74458404
2001 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #67:

score: 0
Accepted
time: 19ms
memory: 78344kb

input:

2013 6
40 34 25 24 15 45 29

output:

2012 35161186
672 1
673 1
1 2
674 2
2 3
675 3
676 3
3 4
677 4
678 4
4 5
679 5
680 5
5 6
681 6
682 6
6 7
683 7
684 7
7 8
685 8
686 8
8 9
687 9
688 9
9 10
689 10
690 10
10 11
691 11
692 11
11 12
693 12
694 12
12 13
695 13
696 13
13 14
697 14
698 14
14 15
699 15
700 15
15 16
701 16
702 16
16 17
703 17
...

result:

ok 

Test #68:

score: 0
Accepted
time: 15ms
memory: 77588kb

input:

199 5
17 8 15 42 48 4

output:

198 2382209
51 1
1 2
52 2
53 2
54 2
2 3
55 3
56 3
57 3
3 4
58 4
59 4
60 4
4 5
61 5
62 5
63 5
5 6
64 6
65 6
66 6
6 7
67 7
68 7
69 7
7 8
70 8
71 8
72 8
8 9
73 9
74 9
75 9
9 10
76 10
77 10
78 10
10 11
79 11
80 11
81 11
11 12
82 12
83 12
84 12
12 13
85 13
86 13
87 13
13 14
88 14
89 14
90 14
14 15
91 15
...

result:

ok 

Test #69:

score: 0
Accepted
time: 16ms
memory: 76704kb

input:

1966 7
37 19 37 24 32 9 37 14

output:

1965 29203766
657 1
1 2
2 3
658 3
659 3
3 4
660 4
661 4
4 5
662 5
663 5
5 6
664 6
665 6
6 7
666 7
667 7
7 8
668 8
669 8
8 9
670 9
671 9
9 10
672 10
673 10
10 11
674 11
675 11
11 12
676 12
677 12
12 13
678 13
679 13
13 14
680 14
681 14
14 15
682 15
683 15
15 16
684 16
685 16
16 17
686 17
687 17
17 18...

result:

ok 

Test #70:

score: 0
Accepted
time: 15ms
memory: 77224kb

input:

2211 5
49 7 4 27 10 6

output:

2210 15935989
554 1
1 2
555 2
556 2
557 2
2 3
558 3
559 3
560 3
3 4
561 4
562 4
563 4
4 5
564 5
565 5
566 5
5 6
567 6
568 6
569 6
6 7
570 7
571 7
572 7
7 8
573 8
574 8
575 8
8 9
576 9
577 9
578 9
9 10
579 10
580 10
581 10
10 11
582 11
583 11
584 11
11 12
585 12
586 12
587 12
12 13
588 13
589 13
590 ...

result:

ok 

Test #71:

score: 0
Accepted
time: 15ms
memory: 77768kb

input:

2187 7
33 36 31 49 29 15 43 18

output:

2186 21094741
1094 1
1 2
1095 2
2 3
1096 3
3 4
1097 4
4 5
1098 5
5 6
1099 6
6 7
1100 7
7 8
1101 8
8 9
1102 9
9 10
1103 10
10 11
1104 11
11 12
1105 12
12 13
1106 13
13 14
1107 14
14 15
1108 15
15 16
1109 16
16 17
1110 17
17 18
1111 18
18 19
1112 19
19 20
1113 20
20 21
1114 21
21 22
1115 22
22 23
1116...

result:

ok 

Test #72:

score: 0
Accepted
time: 16ms
memory: 77896kb

input:

2155 6
20 28 43 19 45 19 40

output:

2154 41581356
1078 1
1 2
1079 2
2 3
1080 3
3 4
1081 4
4 5
1082 5
5 6
1083 6
6 7
1084 7
7 8
1085 8
8 9
1086 9
9 10
1087 10
10 11
1088 11
11 12
1089 12
12 13
1090 13
13 14
1091 14
14 15
1092 15
15 16
1093 16
16 17
1094 17
17 18
1095 18
18 19
1096 19
19 20
1097 20
20 21
1098 21
21 22
1099 22
22 23
1100...

result:

ok 

Test #73:

score: 0
Accepted
time: 22ms
memory: 77120kb

input:

2116 8
15 11 9 46 41 24 2 17 37

output:

2115 57657640
1058 1
1059 1
1 2
1060 2
2 3
1061 3
3 4
1062 4
4 5
1063 5
5 6
1064 6
6 7
1065 7
7 8
1066 8
8 9
1067 9
9 10
1068 10
10 11
1069 11
11 12
1070 12
12 13
1071 13
13 14
1072 14
14 15
1073 15
15 16
1074 16
16 17
1075 17
17 18
1076 18
18 19
1077 19
19 20
1078 20
20 21
1079 21
21 22
1080 22
22 ...

result:

ok 

Test #74:

score: 0
Accepted
time: 25ms
memory: 76748kb

input:

2235 4
46 43 36 45 46

output:

2234 20192476
560 1
1 2
561 2
562 2
563 2
2 3
564 3
565 3
566 3
3 4
567 4
568 4
569 4
4 5
570 5
571 5
572 5
5 6
573 6
574 6
575 6
6 7
576 7
577 7
578 7
7 8
579 8
580 8
581 8
8 9
582 9
583 9
584 9
9 10
585 10
586 10
587 10
10 11
588 11
589 11
590 11
11 12
591 12
592 12
593 12
12 13
594 13
595 13
596 ...

result:

ok 

Test #75:

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

input:

2386 6
33 46 3 3 36 47 3

output:

2385 23421354
597 1
598 1
599 1
600 1
1 2
601 2
602 2
603 2
2 3
604 3
605 3
606 3
3 4
607 4
608 4
609 4
4 5
610 5
611 5
612 5
5 6
613 6
614 6
615 6
6 7
616 7
617 7
618 7
7 8
619 8
620 8
621 8
8 9
622 9
623 9
624 9
9 10
625 10
626 10
627 10
10 11
628 11
629 11
630 11
11 12
631 12
632 12
633 12
12 13
...

result:

ok 

Test #76:

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

input:

2256 5
44 29 21 9 14 34

output:

2255 32619088
565 1
566 1
567 1
1 2
568 2
569 2
2 3
570 3
571 3
572 3
3 4
573 4
574 4
575 4
4 5
576 5
577 5
578 5
5 6
579 6
580 6
581 6
6 7
582 7
583 7
584 7
7 8
585 8
586 8
587 8
8 9
588 9
589 9
590 9
9 10
591 10
592 10
593 10
10 11
594 11
595 11
596 11
11 12
597 12
598 12
599 12
12 13
600 13
601 1...

result:

ok 

Test #77:

score: 0
Accepted
time: 21ms
memory: 78184kb

input:

2262 9
21 4 35 10 47 35 37 25 48 34

output:

2261 84490692
2261 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #78:

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

input:

2257 7
26 17 20 30 32 11 41 13

output:

2256 35113744
752 1
753 1
754 1
1 2
755 2
756 2
2 3
757 3
758 3
3 4
759 4
760 4
4 5
761 5
762 5
5 6
763 6
764 6
6 7
765 7
766 7
7 8
767 8
768 8
8 9
769 9
770 9
9 10
771 10
772 10
10 11
773 11
774 11
11 12
775 12
776 12
12 13
777 13
778 13
13 14
779 14
780 14
14 15
781 15
782 15
15 16
783 16
784 16
1...

result:

ok 

Test #79:

score: 0
Accepted
time: 21ms
memory: 78424kb

input:

226 8
34 21 19 16 21 28 2 37 39

output:

225 5680290
113 1
114 1
1 2
115 2
2 3
116 3
3 4
117 4
4 5
118 5
5 6
119 6
6 7
120 7
7 8
121 8
8 9
122 9
9 10
123 10
10 11
124 11
11 12
125 12
12 13
126 13
13 14
127 14
14 15
128 15
15 16
129 16
16 17
130 17
17 18
131 18
18 19
132 19
19 20
133 20
20 21
134 21
21 22
135 22
22 23
136 23
23 24
137 24
24...

result:

ok 

Test #80:

score: 0
Accepted
time: 21ms
memory: 78196kb

input:

2331 5
36 50 29 20 5 29

output:

2330 25841563
777 1
778 1
779 1
1 2
780 2
781 2
2 3
782 3
783 3
3 4
784 4
785 4
4 5
786 5
787 5
5 6
788 6
789 6
6 7
790 7
791 7
7 8
792 8
793 8
8 9
794 9
795 9
9 10
796 10
797 10
10 11
798 11
799 11
11 12
800 12
801 12
12 13
802 13
803 13
13 14
804 14
805 14
14 15
806 15
807 15
15 16
808 16
809 16
1...

result:

ok 

Test #81:

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

input:

2454 6
34 22 1 23 44 1 27

output:

2453 29880376
1227 1
1228 1
1 2
1229 2
2 3
1230 3
3 4
1231 4
4 5
1232 5
5 6
1233 6
6 7
1234 7
7 8
1235 8
8 9
1236 9
9 10
1237 10
10 11
1238 11
11 12
1239 12
12 13
1240 13
13 14
1241 14
14 15
1242 15
15 16
1243 16
16 17
1244 17
17 18
1245 18
18 19
1246 19
19 20
1247 20
20 21
1248 21
21 22
1249 22
22 ...

result:

ok 

Test #82:

score: 0
Accepted
time: 19ms
memory: 77252kb

input:

2493 1
6 37

output:

2492 199366
2492 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok 

Test #83:

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

input:

2449 9
15 44 43 25 41 9 49 37 50 25

output:

2448 85378953
2448 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #84:

score: 0
Accepted
time: 16ms
memory: 77756kb

input:

2424 4
26 19 47 14 30

output:

2423 21435242
486 1
487 1
1 2
488 2
489 2
490 2
491 2
2 3
492 3
493 3
494 3
495 3
3 4
496 4
497 4
498 4
499 4
4 5
500 5
501 5
502 5
503 5
5 6
504 6
505 6
506 6
507 6
6 7
508 7
509 7
510 7
511 7
7 8
512 8
513 8
514 8
515 8
8 9
516 9
517 9
518 9
519 9
9 10
520 10
521 10
522 10
523 10
10 11
524 11
525 ...

result:

ok 

Test #85:

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

input:

2510 9
50 17 37 5 25 10 5 27 18 35

output:

2509 68458826
2509 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #86:

score: 0
Accepted
time: 28ms
memory: 78336kb

input:

2600 4
16 19 18 19 49

output:

2599 22021756
651 1
652 1
1 2
653 2
654 2
655 2
2 3
656 3
657 3
658 3
3 4
659 4
660 4
661 4
4 5
662 5
663 5
664 5
5 6
665 6
666 6
667 6
6 7
668 7
669 7
670 7
7 8
671 8
672 8
673 8
8 9
674 9
675 9
676 9
9 10
677 10
678 10
679 10
10 11
680 11
681 11
682 11
11 12
683 12
684 12
685 12
12 13
686 13
687 1...

result:

ok 

Test #87:

score: 0
Accepted
time: 24ms
memory: 76820kb

input:

2695 7
25 39 43 5 29 2 49 24

output:

2694 43794209
1348 1
1 2
1349 2
2 3
1350 3
3 4
1351 4
4 5
1352 5
5 6
1353 6
6 7
1354 7
7 8
1355 8
8 9
1356 9
9 10
1357 10
10 11
1358 11
11 12
1359 12
12 13
1360 13
13 14
1361 14
14 15
1362 15
15 16
1363 16
16 17
1364 17
17 18
1365 18
18 19
1366 19
19 20
1367 20
20 21
1368 21
21 22
1369 22
22 23
1370...

result:

ok 

Test #88:

score: 0
Accepted
time: 22ms
memory: 77316kb

input:

2661 10
49 45 22 28 7 50 45 33 33 18 13

output:

2660 107006823
2660 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

result:

ok 

Test #89:

score: 0
Accepted
time: 20ms
memory: 78176kb

input:

2626 7
40 5 15 8 28 13 22 12

output:

2625 63314782
1313 1
1314 1
1 2
1315 2
2 3
1316 3
3 4
1317 4
4 5
1318 5
5 6
1319 6
6 7
1320 7
7 8
1321 8
8 9
1322 9
9 10
1323 10
10 11
1324 11
11 12
1325 12
12 13
1326 13
13 14
1327 14
14 15
1328 15
15 16
1329 16
16 17
1330 17
17 18
1331 18
18 19
1332 19
19 20
1333 20
20 21
1334 21
21 22
1335 22
22 ...

result:

ok 

Test #90:

score: 0
Accepted
time: 15ms
memory: 77880kb

input:

255 4
11 1 4 13 42

output:

254 2896197
52 1
53 1
54 1
1 2
55 2
56 2
57 2
58 2
2 3
59 3
60 3
61 3
62 3
3 4
63 4
64 4
65 4
66 4
4 5
67 5
68 5
69 5
70 5
5 6
71 6
72 6
73 6
74 6
6 7
75 7
76 7
77 7
78 7
7 8
79 8
80 8
81 8
82 8
8 9
83 9
84 9
85 9
86 9
9 10
87 10
88 10
89 10
90 10
10 11
91 11
92 11
93 11
94 11
11 12
95 12
96 12
97 1...

result:

ok 

Test #91:

score: 0
Accepted
time: 16ms
memory: 77360kb

input:

2563 7
40 13 13 37 28 21 8 24

output:

2562 35788764
854 1
855 1
856 1
1 2
857 2
858 2
2 3
859 3
860 3
3 4
861 4
862 4
4 5
863 5
864 5
5 6
865 6
866 6
6 7
867 7
868 7
7 8
869 8
870 8
8 9
871 9
872 9
9 10
873 10
874 10
10 11
875 11
876 11
11 12
877 12
878 12
12 13
879 13
880 13
13 14
881 14
882 14
14 15
883 15
884 15
15 16
885 16
886 16
1...

result:

ok 

Test #92:

score: 0
Accepted
time: 20ms
memory: 78112kb

input:

2768 8
25 18 26 34 13 30 47 6 47

output:

2767 48164850
2767 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #93:

score: 0
Accepted
time: 20ms
memory: 76668kb

input:

2757 8
31 36 12 14 35 43 44 19 21

output:

2756 65276248
1379 1
1 2
1380 2
2 3
1381 3
3 4
1382 4
4 5
1383 5
5 6
1384 6
6 7
1385 7
7 8
1386 8
8 9
1387 9
9 10
1388 10
10 11
1389 11
11 12
1390 12
12 13
1391 13
13 14
1392 14
14 15
1393 15
15 16
1394 16
16 17
1395 17
17 18
1396 18
18 19
1397 19
19 20
1398 20
20 21
1399 21
21 22
1400 22
22 23
1401...

result:

ok 

Test #94:

score: 0
Accepted
time: 28ms
memory: 77636kb

input:

2739 9
43 26 15 47 1 50 41 45 23 49

output:

2738 113605339
2738 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

result:

ok 

Test #95:

score: 0
Accepted
time: 22ms
memory: 77808kb

input:

2719 9
6 17 3 39 27 7 37 36 35 1

output:

2718 47460972
2718 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #96:

score: 0
Accepted
time: 16ms
memory: 77684kb

input:

2793 9
2 50 17 43 35 38 32 6 47 50

output:

2792 119282398
2792 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

result:

ok 

Test #97:

score: 0
Accepted
time: 25ms
memory: 78040kb

input:

2879 8
12 7 41 14 5 9 34 25 16

output:

2878 29178860
2878 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50...

result:

ok 

Test #98:

score: 0
Accepted
time: 17ms
memory: 78560kb

input:

2997 1
6 29

output:

2996 191750
2996 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok 

Test #99:

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

input:

2993 8
2 50 21 40 45 19 9 36 30

output:

2992 81471772
1497 1
1 2
1498 2
2 3
1499 3
3 4
1500 4
4 5
1501 5
5 6
1502 6
6 7
1503 7
7 8
1504 8
8 9
1505 9
9 10
1506 10
10 11
1507 11
11 12
1508 12
12 13
1509 13
13 14
1510 14
14 15
1511 15
15 16
1512 16
16 17
1513 17
17 18
1514 18
18 19
1515 19
19 20
1516 20
20 21
1517 21
21 22
1518 22
22 23
1519...

result:

ok 

Test #100:

score: 0
Accepted
time: 19ms
memory: 77376kb

input:

2993 1
9 45

output:

2992 296217
2992 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

result:

ok