QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473086#2789. SortingRafi22100 ✓145ms19896kbC++142.0kb2024-07-11 21:46:122024-07-11 21:46:12

Judging History

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

  • [2024-07-11 21:46:12]
  • 评测
  • 测评结果:100
  • 用时:145ms
  • 内存:19896kb
  • [2024-07-11 21:46:12]
  • 提交

answer

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

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=2000000007;
ll infl=1000000000000000007;
ll mod=1000000007;



int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[])
{
	bool ok=1;
	FOR(i,0,n-1) ok&=(S[i]==i);
	if(ok) return 0;
    int l=1,r=m,sr,ans=m;
    while(l<=r)
    {
		vector<int>ord(n),p(n),pos(n),odw(n,0);
		FOR(i,0,n-1) 
		{
			ord[i]=i;
			pos[i]=i;
		}
		sr=(l+r)/2;
		FOR(i,0,sr-1) swap(pos[X[i]],pos[Y[i]]); 
		FOR(i,0,n-1) ord[pos[i]]=i;
		FOR(i,0,n-1) p[S[i]]=ord[i];
		FOR(i,0,n-1) debug(p[i]);
		FOR(i,0,n-1) debug(ord[i]);
		vector<pair<int,int>>res;
		FOR(i,0,n-1)
		{
			if(odw[i]) continue;
			int x=i;
			vector<int>V;
			while(!odw[x])
			{
				if(x!=i) V.pb(x);
				debug(i,x);
				odw[x]=1;
				x=p[x];
			}
			for(auto j:V) res.pb({i,j});
		}
		while(sz(res)<sr) res.pb({0,0});
		if(sz(res)==sr)
		{
			ans=sr;
			r=sr-1;
			FOR(i,0,sr-1)
			{
				P[i]=res[i].st;
				Q[i]=res[i].nd;
			}
		}
		else l=sr+1;
	}
	debug(ans);
	vector<int>pos(n);
	FOR(i,0,n-1) pos[S[i]]=i;
	FOR(i,0,ans-1) 
	{
		swap(pos[S[X[i]]],pos[S[Y[i]]]);
		swap(S[X[i]],S[Y[i]]);
		P[i]=pos[P[i]];
		Q[i]=pos[Q[i]];
		swap(pos[S[P[i]]],pos[S[Q[i]]]);
		swap(S[P[i]],S[Q[i]]);
	}
	FOR(i,0,n-1) debug(S[i]);
	FOR(i,0,ans-1) debug(P[i],Q[i]);
	return ans;
}



Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

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

input:

1
0
1
0 0

output:

0

result:

ok correct

Test #2:

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

input:

2
0 1
4
0 0
0 0
0 0
0 0

output:

0

result:

ok correct

Test #3:

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

input:

2
1 0
4
0 0
0 0
0 0
0 0

output:

1
1 0

result:

ok correct

Test #4:

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

input:

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

output:

1
1 0

result:

ok correct

Test #5:

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

input:

4
3 2 0 1
16
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

3
2 1
1 3
3 0

result:

ok correct

Test #6:

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

input:

5
1 4 2 3 0
25
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

2
4 1
1 0

result:

ok correct

Test #7:

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

input:

5
4 2 1 0 3
25
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

3
3 4
4 0
2 1

result:

ok correct

Subtask #2:

score: 12
Accepted

Test #8:

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

input:

1
0
30
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

0

result:

ok correct

Test #9:

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

input:

2
0 1
60
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

0

result:

ok correct

Test #10:

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

input:

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

output:

93
84 6
6 93
93 45
45 70
70 1
1 92
92 69
69 83
83 23
23 77
77 28
28 47
47 88
88 52
52 11
11 49
49 10
10 87
87 22
22 80
80 71
71 50
50 21
21 64
64 72
72 40
40 55
55 31
31 2
2 30
30 67
67 17
17 60
60 81
81 95
95 73
73 43
43 74
74 12
12 3
3 59
59 51
51 5
5 63
63 18
18 48
48 29
29 61
61 34
34 20
20 41
4...

result:

ok correct

Test #11:

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

input:

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

output:

92
3 2
2 13
13 69
69 63
63 51
51 97
97 42
42 22
22 49
49 10
10 7
7 25
25 38
38 19
19 65
65 67
67 30
30 56
56 93
93 9
9 26
26 50
50 8
8 0
61 41
41 60
60 85
85 55
55 95
95 37
37 88
88 72
72 35
35 82
82 73
73 81
81 20
20 75
75 71
71 27
27 39
39 24
24 57
57 92
92 76
76 91
91 96
96 62
62 29
29 44
44 90
9...

result:

ok correct

Test #12:

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

input:

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

output:

95
60 13
13 9
9 37
37 41
41 8
8 19
19 87
87 24
24 23
23 44
44 4
4 83
83 28
28 45
45 55
55 54
54 64
64 88
88 68
68 84
84 53
53 17
17 25
25 49
49 33
33 27
27 79
79 11
11 40
40 31
31 63
63 7
7 39
39 74
74 91
91 1
1 62
62 50
50 16
16 95
95 77
77 58
58 67
67 21
21 29
29 93
93 10
10 78
78 15
15 76
76 69
6...

result:

ok correct

Subtask #3:

score: 16
Accepted

Test #13:

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

input:

2
0 1
60
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1

output:

0

result:

ok correct

Test #14:

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

input:

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

output:

2
2 4
4 1

result:

ok correct

Test #15:

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

input:

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

output:

91
79 40
40 90
90 70
70 76
76 48
48 65
65 35
35 45
45 28
28 27
27 25
25 29
29 9
9 36
36 84
84 54
54 73
73 22
22 21
21 50
50 5
5 32
32 39
39 19
19 52
52 55
55 59
59 88
88 47
47 83
83 93
93 51
51 68
68 38
38 58
58 10
10 46
46 77
77 62
62 60
60 30
30 86
86 37
37 41
41 63
63 14
14 34
34 44
44 16
16 74
7...

result:

ok correct

Test #16:

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

input:

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

output:

92
42 69
69 11
11 98
98 54
54 92
92 40
40 14
14 50
50 49
49 15
15 27
27 79
79 70
70 73
73 4
4 13
13 66
66 18
18 8
8 62
62 78
78 83
83 28
28 0
81 32
32 46
46 9
9 39
39 60
60 57
57 41
41 33
33 16
16 2
2 0
61 48
48 55
55 43
43 94
94 72
72 31
31 77
77 65
65 38
38 24
24 53
53 56
56 21
21 84
84 68
68 44
4...

result:

ok correct

Test #17:

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

input:

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

output:

97
83 35
35 29
29 85
85 49
49 16
16 21
21 98
98 80
80 32
32 93
93 76
76 70
70 58
58 97
97 94
94 22
22 74
74 30
30 17
17 48
48 8
8 23
23 86
86 69
69 67
67 60
60 11
11 9
9 28
28 36
36 25
25 51
51 39
39 77
77 31
31 55
55 71
71 13
13 26
26 78
78 24
24 33
33 20
20 84
84 41
41 79
79 15
15 34
34 57
57 47
4...

result:

ok correct

Test #18:

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

input:

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

output:

2
3 2
0 0

result:

ok correct

Subtask #4:

score: 18
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #19:

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

input:

1
0
30
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

output:

0

result:

ok correct

Test #20:

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

input:

2
0 1
60
1 0
0 1
1 0
0 1
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
1 0
1 0
0 1
1 0
0 1
1 0
1 0
1 0
1 0
1 0
0 1
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
0 1
1 0
1 0
0 1
1 0
1 0
0 1
0 1
0 1
0 1
1 0
0 1
1 0
1 0
1 0

output:

0

result:

ok correct

Test #21:

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

input:

481
264 22 307 266 238 227 68 26 13 12 384 162 410 306 374 311 442 38 407 310 280 308 333 146 326 381 367 110 190 33 141 468 153 393 157 415 229 75 276 392 349 348 179 445 317 64 78 20 323 257 292 395 129 259 165 398 151 219 14 116 338 188 243 61 150 84 72 340 155 133 459 464 248 433 124 399 177 62 ...

output:

473
426 389
389 331
331 228
228 452
452 373
373 86
86 447
447 191
191 158
158 357
357 43
43 462
462 265
265 111
111 312
312 478
478 140
140 467
467 273
273 27
27 181
181 372
372 401
401 282
282 375
375 376
376 6
6 7
7 55
55 322
322 17
17 298
298 205
205 267
267 101
101 12
12 397
397 443
443 94
94 34...

result:

ok correct

Test #22:

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

input:

478
458 446 125 326 318 327 263 67 453 296 46 116 270 440 323 38 181 235 415 412 95 365 133 397 157 441 348 223 459 449 149 168 59 107 171 262 328 450 289 314 141 139 29 393 211 477 146 239 433 142 269 145 342 155 238 172 206 23 108 31 48 117 180 424 50 147 325 468 161 291 272 130 93 472 245 207 154...

output:

476
253 133
133 138
138 349
349 388
388 328
328 36
36 115
115 179
179 259
259 380
380 378
378 99
99 441
441 25
25 301
301 455
455 299
299 336
336 212
212 102
102 471
471 3
3 68
68 298
298 270
270 340
340 324
324 435
435 257
257 193
193 262
262 70
70 106
106 224
224 120
120 61
61 399
399 22
22 276
27...

result:

ok correct

Test #23:

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

input:

496
426 495 20 100 83 50 3 247 94 52 290 45 179 160 344 239 270 133 492 398 131 476 271 436 69 351 401 494 111 76 393 432 431 207 53 350 24 288 278 359 413 253 181 166 186 336 35 173 209 448 352 364 188 434 203 38 439 32 328 285 213 112 47 128 136 303 49 180 444 132 177 114 287 475 161 483 14 108 66...

output:

490
403 415
415 234
234 470
470 129
129 72
72 418
418 405
405 88
88 490
490 21
21 247
247 330
330 260
260 50
50 104
104 366
366 463
463 262
262 232
232 454
454 14
14 252
252 494
494 422
422 244
244 486
486 203
203 2
2 114
114 62
62 436
436 8
8 310
310 435
435 84
84 421
421 112
112 142
142 384
384 21...

result:

ok correct

Test #24:

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

input:

484
307 290 7 454 181 133 142 213 413 207 146 153 236 111 320 453 476 103 316 158 235 388 150 155 329 297 196 345 335 197 173 0 156 59 357 85 161 280 229 98 412 187 42 226 244 203 99 475 223 81 56 309 273 87 159 317 50 313 199 366 185 409 172 483 447 427 71 284 330 30 73 414 154 70 302 417 113 107 2...

output:

422
31 307
307 462
462 171
171 118
118 449
449 426
426 282
282 456
456 91
91 73
73 70
70 405
405 0
321 290
290 400
400 482
482 297
297 25
25 250
250 7
7 2
2 409
409 61
61 438
438 213
213 437
437 142
142 295
295 6
6 113
113 216
216 203
203 45
45 472
472 350
350 408
408 264
264 435
435 10
10 146
146 3...

result:

ok correct

Test #25:

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

input:

496
145 300 465 228 235 186 373 183 142 208 278 11 410 286 392 245 44 470 211 368 283 240 265 120 30 68 71 158 263 356 439 243 27 311 86 134 201 33 319 371 254 181 231 89 214 435 113 59 48 151 317 143 320 195 377 426 408 303 22 47 149 330 180 175 412 140 102 204 381 441 50 258 232 105 266 52 122 423...

output:

145
465 2
198 228
235 4
438 410
410 12
392 14
471 470
239 19
283 20
240 21
165 120
120 23
258 71
32 158
158 27
282 263
24 30
37 33
110 86
86 34
476 35
319 38
363 40
342 231
231 42
89 43
435 45
113 46
70 317
317 50
95 195
148 377
377 54
417 426
426 55
406 303
265 58
330 61
446 140
140 65
325 102
117 ...

result:

ok correct

Test #26:

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

input:

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

output:

270
1 82
82 256
256 368
368 319
319 127
127 462
462 456
456 112
112 148
148 255
255 262
262 266
266 159
159 470
470 227
227 393
393 174
174 270
270 28
28 265
265 453
453 197
197 102
102 189
189 163
163 290
290 298
298 376
376 436
436 132
132 233
233 17
17 89
89 246
2 335
335 64
64 150
150 283
283 31...

result:

ok correct

Test #27:

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

input:

476
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 129 91 92 93 94 95 96 97 98 99 100 1...

output:

473
0 258
258 269
269 159
159 276
276 55
55 333
333 250
250 454
454 425
425 147
147 452
452 419
419 411
411 291
291 379
379 169
169 392
392 56
56 142
142 224
224 80
80 48
48 353
353 349
349 263
263 407
407 238
238 23
23 315
315 11
11 393
393 154
154 88
88 294
294 218
218 105
105 275
275 436
436 90
9...

result:

ok correct

Subtask #5:

score: 20
Accepted

Test #28:

score: 20
Accepted
time: 1ms
memory: 3964kb

input:

1800
530 1775 466 953 230 1179 944 752 990 1316 275 1029 158 152 1673 1706 172 115 599 1661 131 699 1112 454 551 1059 291 495 28 67 773 480 839 462 1210 757 879 285 439 3 1429 820 26 1023 942 199 356 625 1705 1421 144 1529 716 7 1485 1027 1599 696 517 1353 456 1389 273 1363 1414 1177 718 41 777 1621...

output:

1794
688 490
490 1687
1687 1024
1024 421
421 287
287 1029
1029 764
764 1320
1320 1257
1257 877
877 801
801 1384
1384 1363
1363 63
63 1353
1353 59
59 93
93 1783
1783 1289
1289 1785
1785 1032
1032 904
904 270
270 908
908 1387
1387 1600
1600 556
556 641
641 440
440 821
821 1608
1608 132
132 399
399 546...

result:

ok correct

Test #29:

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

input:

1950
1718 335 1071 714 1080 1828 1472 410 553 1269 297 401 1021 621 1763 528 205 1231 406 5 715 876 1474 1110 653 862 838 291 1092 549 955 1334 1044 300 1070 720 1877 484 1597 1948 1078 28 87 1193 505 1024 1259 63 852 960 633 1573 713 504 15 820 1852 752 1601 1168 471 1903 499 693 1209 1492 56 908 9...

output:

1944
1223 535
535 298
298 999
999 1538
1538 1342
1342 1088
1088 404
404 1646
1646 1896
1896 1167
1167 1152
1152 1084
1084 1214
1214 416
416 1333
1333 579
579 1769
1769 1783
1783 1316
1316 753
753 1262
1262 1329
1329 409
409 1824
1824 549
549 29
29 410
410 7
7 751
751 1581
1581 1885
1885 417
417 1724...

result:

ok correct

Test #30:

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

input:

1853
452 1299 444 1527 510 1801 34 1178 1589 1782 342 1800 735 761 879 999 1122 1772 236 566 1459 1256 1149 1498 1827 1027 715 1377 6 306 1811 950 500 890 196 1825 1568 1157 943 1422 475 1237 1792 1796 1363 1217 889 968 1439 1116 322 795 1088 1358 1833 96 118 543 1337 207 876 1144 805 215 1433 903 1...

output:

1844
1354 552
552 676
676 1660
1660 1099
1099 728
728 1249
1249 1273
1273 798
798 1593
1593 1243
1243 938
938 1160
1160 227
227 1715
1715 1465
1465 1464
1464 684
684 1193
1193 1349
1349 391
391 272
272 1029
1029 1201
1201 213
213 33
33 320
320 1199
1199 343
343 443
443 817
817 527
527 40
40 1616
161...

result:

ok correct

Test #31:

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

input:

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

output:

0

result:

ok correct

Test #32:

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

input:

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

output:

134
5 540
25 1610
27 1604
39 1305
65 831
66 295
295 679
67 776
68 1991
69 121
71 1306
81 1381
90 101
93 1892
113 133
955 115
124 885
563 157
169 1479
200 1256
201 1739
205 1580
206 1200
1200 1693
1693 1896
210 1912
213 1583
1486 1829
1829 214
230 1057
237 460
245 1156
1156 271
1383 248
250 1006
263 ...

result:

ok correct

Test #33:

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

input:

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

output:

377
0 516
516 475
1 848
848 591
591 1156
5 640
640 355
18 570
570 1185
1185 1317
1317 1612
20 883
26 173
173 247
27 459
459 1196
1196 420
420 508
508 593
593 1638
1638 62
34 1504
39 1929
1929 199
199 855
43 554
1259 359
359 46
53 514
54 1017
56 389
59 1226
1226 336
336 870
60 1205
63 1685
1685 178
6...

result:

ok correct

Test #34:

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

input:

1999
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 127 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 ...

output:

1080
2 1414
1414 1868
1868 982
982 96
96 1254
1254 1883
1883 984
984 1359
1359 1380
1380 790
790 1647
1647 1482
1482 1875
1875 64
64 1746
1746 867
867 1124
1124 1405
1405 909
909 1474
1474 1689
1689 1027
1027 1272
1272 405
405 983
983 327
327 1657
1657 810
810 1754
1754 750
750 1923
1923 1764
1764 8...

result:

ok correct

Test #35:

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

input:

1901
952 410 986 1281 736 1411 1256 622 375 1423 718 1153 1238 643 120 1336 1097 881 1140 1395 1195 847 925 967 280 1859 966 360 815 770 634 1774 1359 1871 1589 618 991 571 1704 170 1548 1791 225 741 1561 35 1334 1632 203 894 728 1681 1849 22 1152 1719 701 1886 1037 1309 1576 993 1350 1643 893 1888 ...

output:

1897
1790 1894
1894 1739
1739 194
194 1316
1316 1358
1358 1879
1879 511
511 213
213 804
804 23
23 854
854 1223
1223 1176
1176 1752
1752 1441
1441 1899
1899 1356
1356 372
372 1519
1519 1196
1196 1145
1145 1463
1463 118
118 1528
1528 1015
1015 382
382 1757
1757 93
93 982
982 243
243 999
999 684
684 17...

result:

ok correct

Test #36:

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

input:

1931
1361 1614 1425 1627 1210 1778 166 420 1747 1792 1060 1914 611 833 1280 86 1754 1194 762 185 488 1368 1794 1153 1466 1689 1185 168 1622 1582 959 197 103 1809 1586 436 633 853 463 738 820 630 159 398 150 1370 558 281 1849 483 1691 350 1867 1871 1392 1791 1697 926 639 1865 1063 1726 262 1009 495 1...

output:

1923
1611 284
284 1666
1666 1570
1570 973
973 1906
1906 426
426 233
233 1008
1008 87
87 808
808 1225
1225 820
820 1818
1818 26
26 1545
1545 406
406 174
174 470
470 1484
1484 506
506 527
527 394
394 1698
1698 723
723 706
706 585
585 1032
1032 924
924 144
144 1510
1510 1632
1632 300
300 696
696 1862
1...

result:

ok correct

Test #37:

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

input:

1938
428 1641 1051 1154 1556 814 986 237 1557 1082 84 1382 1823 1591 1779 1565 193 574 1683 1259 405 393 366 644 612 562 303 1567 997 1422 868 132 74 1508 1002 965 1752 500 1148 529 1119 1841 930 1608 1472 310 1435 261 705 908 588 1710 722 1427 1825 1256 1175 379 45 902 1861 62 729 1303 759 766 1022...

output:

1928
1460 1912
1912 1573
1573 810
810 425
425 1880
1880 1772
1772 1066
1066 295
295 668
668 1738
1738 361
361 1313
1313 383
383 318
318 591
591 224
224 1364
1364 691
691 571
571 905
905 1016
1016 1628
1628 1372
1372 1746
1746 775
775 908
908 49
49 981
981 1896
1896 218
218 1375
1375 562
562 1351
135...

result:

ok correct

Test #38:

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

input:

1997
1053 110 1738 1025 1245 1257 472 471 13 1215 1811 1371 476 1631 1028 892 1191 20 1323 868 435 1063 870 758 1538 155 1105 27 987 1345 1228 1473 452 1092 1561 1874 1417 95 252 565 1315 1389 533 1078 1259 1440 772 0 1588 1750 1451 644 659 1161 173 200 1680 1040 1827 1567 1069 12 1730 866 1493 65 5...

output:

1693
47 1228
1228 30
30 1053
1053 893
893 1207
1207 0
137 174
174 1694
1694 180
180 569
569 1822
1822 1043
1043 1749
1749 71
71 110
110 1
1603 1935
1935 1741
1741 1107
1107 161
161 1802
1802 320
320 1865
1865 121
121 1621
1621 1976
1976 1309
1309 604
604 1030
1030 849
849 86
86 1738
1738 907
907 521...

result:

ok correct

Test #39:

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

input:

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

output:

1091
1 1179
1179 1060
1060 1328
1328 347
347 299
299 87
87 1720
1720 1987
1987 657
657 1248
1248 1233
1233 121
121 1111
1111 1601
1601 1399
1399 852
852 1694
1694 1597
1597 206
206 1940
1940 897
897 125
125 255
255 1486
1486 1847
1847 1354
1354 832
832 331
331 465
465 1300
1300 1333
1333 872
872 838...

result:

ok correct

Test #40:

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

input:

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

output:

1959
0 928
928 331
331 43
43 744
744 1575
1575 932
932 1847
1847 782
782 211
211 401
401 668
668 1960
1960 74
74 1701
1701 1919
1919 16
16 1804
1804 50
50 1464
1464 555
555 361
361 984
984 1010
1010 1788
1788 749
749 1709
1709 1289
1289 340
340 1583
1583 1070
1070 1479
1479 389
389 1054
1054 1670
16...

result:

ok correct

Test #41:

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

input:

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

output:

2
1779 1471
0 0

result:

ok correct

Subtask #6:

score: 26
Accepted

Dependency #5:

100%
Accepted

Test #42:

score: 26
Accepted
time: 104ms
memory: 17876kb

input:

176900
167810 159384 90550 63101 76883 19925 161149 18578 132157 136198 141834 156609 167914 129523 2878 165972 95279 65282 30261 94853 37236 41515 166488 123502 141101 86565 153657 72526 396 92614 23189 1661 167567 100107 155037 35542 99140 171977 171544 123048 107611 71527 111368 88756 149185 9360...

output:

176885
5823 54698
54698 131426
131426 100087
100087 93160
93160 15940
15940 12552
12552 32570
32570 162170
162170 142363
142363 147290
147290 80665
80665 169113
169113 131984
131984 76148
76148 6689
6689 117625
117625 120498
120498 66662
66662 51776
51776 132103
132103 3643
3643 136903
136903 94186
...

result:

ok correct

Test #43:

score: 0
Accepted
time: 118ms
memory: 18548kb

input:

180601
172380 49504 27207 3423 41891 140536 126137 40192 90592 127987 124918 9486 152764 76028 76578 51283 40029 108361 93576 1341 36411 19763 103182 57530 103033 111456 32419 24822 89698 42054 101746 78793 103184 136054 135074 170297 146325 170251 21191 78975 68633 116257 103827 106102 162889 14512...

output:

180588
124503 57341
57341 150446
150446 109164
109164 52312
52312 72582
72582 105082
105082 100208
100208 42024
42024 71818
71818 171779
171779 70906
70906 95783
95783 148987
148987 158998
158998 160757
160757 131303
131303 36775
36775 97840
97840 117952
117952 80527
80527 143331
143331 92676
92676 ...

result:

ok correct

Test #44:

score: 0
Accepted
time: 131ms
memory: 18700kb

input:

190000
155277 81364 16113 73641 59637 140074 33594 60852 167804 149502 15249 35894 69246 132504 37548 26618 81511 141393 147548 24346 7165 123128 175784 74022 121283 80377 116823 111912 149688 96762 34103 104558 142346 82209 136360 40339 28418 119696 9573 42868 81005 59704 115658 173964 158009 43922...

output:

189985
128206 25947
25947 30593
30593 161998
161998 97555
97555 121408
121408 65764
65764 31059
31059 72850
72850 53824
53824 142261
142261 182700
182700 99972
99972 134150
134150 17290
17290 79744
79744 5508
5508 8013
8013 184272
184272 178157
178157 173664
173664 52630
52630 140987
140987 186165
1...

result:

ok correct

Test #45:

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

input:

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

output:

0

result:

ok correct

Test #46:

score: 0
Accepted
time: 123ms
memory: 18112kb

input:

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

output:

89748
2 52244
52244 43582
43582 184974
184974 21063
21063 8319
8319 71027
71027 65683
65683 9672
9672 35842
35842 78364
3 75666
75666 26246
26246 178167
4 120858
120858 192010
192010 32977
5 10597
10597 108202
108202 176198
176198 68754
68754 20690
20690 49271
49271 136622
136622 42303
42303 94179
9...

result:

ok correct

Test #47:

score: 0
Accepted
time: 125ms
memory: 18404kb

input:

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

output:

100444
1 145706
145706 18961
18961 63788
63788 34141
34141 168376
168376 50165
50165 52789
52789 70106
70106 93770
93770 160379
160379 118843
118843 73015
73015 175666
175666 170197
170197 102744
102744 89280
89280 8587
8587 20455
20455 71611
71611 87940
87940 12737
12737 113541
113541 28483
28483 2...

result:

ok correct

Test #48:

score: 0
Accepted
time: 131ms
memory: 18380kb

input:

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

output:

102949
0 50834
50834 126291
126291 126919
126919 140646
140646 56867
56867 86954
86954 28357
28357 130320
130320 15314
15314 113317
113317 45437
1 66147
66147 78965
78965 67580
67580 185065
185065 78746
78746 111436
111436 82218
2 72016
72016 24779
24779 55244
55244 23204
4 6329
6329 12788
5 170827
...

result:

ok correct

Test #49:

score: 0
Accepted
time: 115ms
memory: 18928kb

input:

193129
36602 123872 92038 45146 138692 111345 188441 38874 91571 40957 134717 29367 19348 43950 30107 169548 95423 20615 37890 24013 43534 56756 81846 81665 44142 51120 180128 191175 155099 72840 184568 93861 80314 90359 189897 714 93862 77927 44624 23382 86361 118437 115484 86518 100371 84582 12335...

output:

193113
109966 16294
16294 150065
150065 60261
60261 50070
50070 63275
63275 176078
176078 190875
190875 120573
120573 165941
165941 70976
70976 54284
54284 153742
153742 66239
66239 106267
106267 101187
101187 6793
6793 79189
79189 176276
176276 28075
28075 33450
33450 142620
142620 177206
177206 99...

result:

ok correct

Test #50:

score: 0
Accepted
time: 116ms
memory: 18944kb

input:

197082
28948 99935 148708 46451 122696 180672 62930 125162 102390 178828 36655 81146 108094 50099 58749 177353 187400 182745 51049 117239 46107 132994 126349 134844 20491 77064 156426 77316 106562 74474 181231 51810 115214 17483 98735 11537 154284 152530 31318 32324 150103 162145 377 111950 32190 84...

output:

197073
145461 117984
117984 128728
128728 184822
184822 122807
122807 119110
119110 6028
6028 1441
1441 166
166 170581
170581 21891
21891 52894
52894 111791
111791 167101
167101 42998
42998 6828
6828 74303
74303 124685
124685 150794
150794 57235
57235 188316
188316 149359
149359 6919
6919 109979
109...

result:

ok correct

Test #51:

score: 0
Accepted
time: 125ms
memory: 18648kb

input:

194300
41456 157650 130220 26552 100104 39688 171793 93878 171968 42386 15076 119236 116984 147030 178130 84543 41422 78012 62905 182069 27860 51578 123684 182555 79509 132548 171199 184307 163260 137221 40321 193521 22658 163921 153451 81135 146421 61739 37826 184064 100949 1221 27789 179291 15206 ...

output:

194290
49723 150692
150692 68009
68009 82200
82200 141775
141775 78691
78691 50412
50412 88650
88650 174008
174008 181117
181117 192663
192663 106552
106552 179422
179422 98144
98144 30943
30943 107784
107784 54090
54090 122404
122404 172715
172715 157708
157708 187943
187943 67227
67227 41153
41153...

result:

ok correct

Test #52:

score: 0
Accepted
time: 141ms
memory: 18532kb

input:

191745
86160 177973 190897 101427 58207 52429 103273 57783 65873 49221 161353 23941 99019 125297 40852 27805 14133 40994 81091 37037 21432 47533 119915 102063 92390 79753 118310 157456 132054 38761 115430 33036 71721 54738 176381 140861 147078 36903 123109 71733 46877 173730 187571 7820 33867 26827 ...

output:

191732
150103 110602
110602 16618
16618 180904
180904 8044
8044 169555
169555 147454
147454 62826
62826 186535
186535 61702
61702 104438
104438 147064
147064 117759
117759 157416
157416 47501
47501 151019
151019 162682
162682 151929
151929 56222
56222 183401
183401 50310
50310 79046
79046 170083
170...

result:

ok correct

Test #53:

score: 0
Accepted
time: 120ms
memory: 18964kb

input:

199993
196446 158206 8206 10499 39868 129031 121632 148457 183086 75548 11957 13065 15359 17847 118402 17577 159823 30468 24361 103231 121626 59655 36996 187439 89929 192793 20197 28808 16555 137308 105716 56425 198490 164384 8584 47629 83558 155060 148041 175988 3886 132588 15792 32028 104991 14846...

output:

99996
99339 137034
137034 165662
165662 87504
87504 127938
127938 158551
158551 178681
178681 18032
18032 132261
132261 36896
36896 158742
158742 131301
131301 156561
156561 90556
90556 177513
177513 188964
188964 77323
77323 171887
171887 32890
32890 24353
24353 127171
127171 86924
86924 99232
9923...

result:

ok correct

Test #54:

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

input:

195962
0 143495 94457 139954 64590 53700 118663 178237 93365 76238 190312 47039 180296 27740 3019 173316 180035 69779 93653 122287 57697 21 119951 130009 15368 145558 129234 63611 55030 29 189665 107778 157921 184944 79827 118642 86050 82957 86225 39 29493 124696 114418 173586 84617 177846 170864 11...

output:

84206
56335 30778
30778 33221
33221 130224
130224 25252
25252 28278
28278 180905
180905 51636
51636 44775
44775 141571
141571 103988
103988 119606
119606 65630
65630 5202
5202 19741
19741 91292
91292 192415
192415 2797
2797 110234
110234 148416
148416 141714
141714 82668
82668 20851
20851 166954
166...

result:

ok correct

Test #55:

score: 0
Accepted
time: 145ms
memory: 18088kb

input:

194842
100154 140138 48998 98453 130678 177133 46195 8423 62509 72873 77452 122206 42181 60275 170586 2358 7988 89849 185284 193691 59370 185794 5218 23270 118843 81380 57130 150638 52947 187734 187310 168413 153988 136321 38186 163329 189331 126207 137943 84857 145378 167961 161479 69302 31915 1202...

output:

182153
190730 164620
164620 140926
140926 76137
76137 145327
145327 154166
154166 114112
114112 77634
77634 3994
3994 119966
119966 151548
151548 87188
87188 68668
68668 51496
51496 160470
160470 175646
175646 182677
182677 91319
91319 161013
161013 111939
111939 122744
122744 64638
64638 108240
108...

result:

ok correct

Test #56:

score: 0
Accepted
time: 144ms
memory: 18268kb

input:

192864
140597 66570 121427 116752 26792 80717 160186 76426 8 89413 178636 77175 26030 47446 80214 37113 6890 186652 99224 16670 42488 160907 6475 13753 93053 55091 124543 86129 121212 126899 190219 159959 130785 94656 182197 40626 190748 71684 29400 127366 187275 144333 66541 159353 56469 45 46 1133...

output:

165493
81100 140597
140597 55197
55197 117434
117434 46925
46925 91173
91173 27168
27168 54445
54445 19433
19433 177445
177445 33029
33029 154164
154164 10651
10651 104878
104878 124293
124293 73530
73530 47707
47707 97351
97351 165008
165008 69346
69346 132514
132514 127924
127924 112021
112021 971...

result:

ok correct

Test #57:

score: 0
Accepted
time: 92ms
memory: 17780kb

input:

197205
69791 7278 144655 44140 100294 77302 123723 171433 104856 173242 169410 67899 36966 171145 136488 47079 48081 152021 59592 5911 4574 162108 173932 54582 62863 110098 59669 47193 129654 106687 152256 89688 184321 178761 50076 26558 84676 120349 3492 76839 83222 138603 78108 16086 42321 191702 ...

output:

49301
7278 1
144655 2
44140 3
100294 4
77302 5
123723 6
104856 8
173242 9
67899 11
171145 13
47079 15
152021 17
5911 19
173932 22
62863 24
59669 26
47193 27
89688 31
184321 32
178761 33
26558 35
120349 37
3492 38
76839 39
16086 43
191702 45
87915 47
101863 48
13181 49
283 50
178223 52
69114 55
43557...

result:

ok correct

Test #58:

score: 0
Accepted
time: 130ms
memory: 18648kb

input:

197131
84406 80027 110287 44746 131371 146934 42426 65970 150332 170783 65657 1953 162645 190993 109274 124958 51133 84371 52975 45289 169245 91663 107556 94239 181471 104596 71086 182854 165285 38597 66664 7262 124939 9815 82726 155117 130064 161982 165615 141978 54973 19100 50015 109085 117973 118...

output:

168671
84406 143935
143935 48789
48789 72726
72726 85557
85557 6792
6792 84865
84865 0
80027 1
110287 2
44746 3
131371 4
146934 193376
193376 105707
105707 190456
190456 160084
160084 104853
104853 114089
114089 34427
34427 148647
148647 15447
15447 158682
158682 5
5 89519
89519 181819
181819 9879
9...

result:

ok correct

Test #59:

score: 0
Accepted
time: 104ms
memory: 19896kb

input:

190716
70694 127495 127683 172932 35760 161055 89535 88848 86329 70488 159904 154657 123716 114250 17532 30359 18636 56168 87024 174259 84439 39232 146857 23700 109966 77964 87980 58575 44910 187918 44705 123208 129478 100467 24819 82211 54590 167945 186629 189101 150929 88606 28837 150355 60022 149...

output:

190706
3201 37509
37509 106126
106126 25153
25153 188243
188243 33704
33704 65326
65326 171719
171719 23927
23927 60948
60948 54187
54187 44490
44490 87980
87980 26
26 142374
142374 30240
30240 92582
92582 168795
168795 44459
44459 141726
141726 89813
89813 117962
117962 168870
168870 79625
79625 69...

result:

ok correct

Test #60:

score: 0
Accepted
time: 119ms
memory: 18648kb

input:

193898
85269 174015 77811 28051 118737 97733 40719 89809 27239 143398 80856 147511 63066 169396 188622 137055 75691 19603 26753 21153 38282 19883 184352 116056 74924 109097 83545 91598 188816 130408 12005 58299 179552 132499 184991 172525 19246 46965 82109 14127 45042 61971 139287 156790 158325 1053...

output:

193877
175527 165826
165826 167219
167219 55055
55055 57414
57414 16603
16603 105942
105942 16938
16938 78131
78131 188249
188249 69906
69906 145423
145423 156553
156553 180916
180916 114912
114912 174707
174707 149731
149731 20343
20343 175709
175709 1148
1148 91411
91411 46210
46210 45023
45023 16...

result:

ok correct

Test #61:

score: 0
Accepted
time: 109ms
memory: 19236kb

input:

193451
73331 167267 1859 26632 182171 73089 171348 172101 254 125155 89420 155531 85116 116670 120195 104715 81962 173779 54516 70099 186190 71017 67533 23137 114603 120956 148961 4395 85938 127836 173745 186046 50370 28206 98366 112565 66018 46642 74053 48767 7112 15058 176808 908 73048 45225 60762...

output:

193228
126017 149602
149602 91421
91421 66215
66215 68971
68971 29764
29764 78513
78513 93632
93632 141212
141212 12992
12992 36337
36337 76933
76933 77378
77378 42746
42746 132011
132011 15695
15695 89583
89583 76695
76695 105755
105755 103782
103782 145223
145223 127780
127780 107113
107113 146932...

result:

ok correct

Test #62:

score: 0
Accepted
time: 120ms
memory: 18904kb

input:

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

output:

95351
0 178113
178113 33557
33557 22437
22437 32127
32127 57592
57592 174804
174804 183346
183346 131950
131950 149828
149828 64346
64346 70948
70948 98158
98158 135960
135960 33444
33444 166803
166803 187205
187205 158345
158345 150108
150108 93548
93548 134881
134881 55439
55439 94936
94936 34269
...

result:

ok correct

Test #63:

score: 0
Accepted
time: 31ms
memory: 18812kb

input:

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

output:

2
139084 152764
0 0

result:

ok correct

Test #64:

score: 0
Accepted
time: 121ms
memory: 19644kb

input:

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

output:

199698
0 111889
111889 108898
108898 58719
58719 115518
115518 70187
70187 164611
164611 173316
173316 52572
52572 76597
76597 109329
109329 90947
90947 171226
171226 88443
88443 140194
140194 90269
90269 1603
1603 93624
93624 6081
6081 63513
63513 1635
1635 92948
92948 53809
53809 39020
39020 37981...

result:

ok correct

Test #65:

score: 0
Accepted
time: 103ms
memory: 18184kb

input:

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

output:

191784
0 81188
81188 150900
150900 188507
188507 21997
21997 155833
155833 80327
80327 70627
70627 180880
180880 142160
142160 75707
75707 87522
87522 153977
153977 183150
183150 8257
8257 154701
154701 139562
139562 149786
149786 111423
111423 129098
129098 174027
174027 121928
121928 32187
32187 9...

result:

ok correct

Test #66:

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

input:

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

output:

193069
0 154950
154950 38599
38599 50508
50508 22973
22973 144145
144145 150806
150806 122692
122692 76367
76367 22766
22766 87277
87277 7016
7016 15316
15316 166684
166684 138726
138726 144865
144865 29857
29857 180671
180671 76291
76291 124669
124669 89076
89076 192731
192731 173292
173292 191733
...

result:

ok correct