QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124451#2789. Sortingvalerikk#74 3ms12148kbC++172.1kb2023-07-14 20:04:312024-07-04 00:40:38

Judging History

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

  • [2024-07-04 00:40:38]
  • 评测
  • 测评结果:74
  • 用时:3ms
  • 内存:12148kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 20:04:31]
  • 提交

answer

#include "sorting.h"
#include <bits/stdc++.h>

using namespace std;

namespace {

const int N = 2005;
const int M = 6e5 + 7;

int n, s[N];
int m, x[M], y[M];
int ansp[M], ansq[M];
int ansr;
int curs[N], s1[N];
bool used[N];
int pos[N];

}

int findSwapPairs(int grdn, int grds[], int grdm, int grdx[], int grdy[], int grdp[], int grdq[]) {
	n = grdn;
	for (int i = 0; i < n; ++i) {
		s[i] = grds[i];
	}
	m = grdm;
	for (int i = 0; i < m; ++i) {
		x[i] = grdx[i];
		y[i] = grdy[i];
	}
	int l = -1, r = m + 1;
	while (r - l > 1) {
		int mid = (l + r) / 2;
		for (int i = 0; i < n; ++i) {
			curs[i] = s[i];
		}
		for (int i = 0; i < mid; ++i) {
			swap(curs[x[i]], curs[y[i]]);
		}
		int cnt = 0;
		for (int i = 0; i < n; ++i) {
			used[i] = 0;
		}
		for (int i = 0; i < n; ++i) {
			if (!used[i]) {
				int v = i;
				while (!used[v]) {
					used[v] = 1;
					v = curs[v];
				}
				++cnt;
			}
		}
		if (n - cnt <= mid) {
			r = mid;
		} else {
			l = mid;
		}
	}
	for (int i = 0; i < n; ++i) {
		curs[i] = s[i];
	}
	for (int i = 0; i < r; ++i) {
		swap(curs[x[i]], curs[y[i]]);
	}
	vector<vector<int>> kek;
	for (int i = 0; i < n; ++i) {
		used[i] = 0;
	}
	for (int i = 0; i < n; ++i) {
		if (!used[i]) {
			int v = i;
			vector<int> lol;
			while (!used[v]) {
				used[v] = 1;
				lol.push_back(v);
				v = curs[v];
			}
			kek.push_back(lol);
		}
	}
	assert(r >= n - (int)kek.size());
	ansr = r;
	for (int i = 0; i < n; ++i) {
		s1[i] = curs[i];
	}
	vector<pair<int, int>> swaps;
	for (auto lol : kek) {
		for (int i = 1; i < (int)lol.size(); ++i) {
			swaps.push_back({s1[lol[0]], s1[lol[i]]});
			swap(s1[lol[0]], s1[lol[i]]);
		}
	}
	while ((int)swaps.size() < r) {
		swaps.push_back({0, 0});
	}
	assert((int)swaps.size() == r);
	for (int i = 0; i < n; ++i) {
		s1[i] = curs[i];
	}
	for (int i = 0; i < n; ++i) {
		pos[s1[i]] = i;
	}
	for (int i = r - 1; i >= 0; --i) {
		int x1 = swaps[r - i - 1].first;
		int y1 = swaps[r - i - 1].second;
		int px1 = pos[x1];
		int py1 = pos[y1];
		ansp[i] = px1;
		ansq[i] = py1;
		swap(pos[s1[x[i]]], pos[s1[y[i]]]);
		swap(s1[x[i]], s1[y[i]]);
	}
	for (int i = 0; i < ansr; ++i) {
		grdp[i] = ansp[i];
		grdq[i] = ansq[i];
	}
	return ansr;
}



Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 8
Accepted

Test #1:

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

input:

1
0
1
0 0

output:

0

result:

ok correct

Test #2:

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

input:

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

output:

0

result:

ok correct

Test #3:

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

input:

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

output:

1
0 1

result:

ok correct

Test #4:

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

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

result:

ok correct

Test #5:

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

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

result:

ok correct

Test #6:

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

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

result:

ok correct

Test #7:

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

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

result:

ok correct

Subtask #2:

score: 12
Accepted

Test #8:

score: 12
Accepted
time: 1ms
memory: 7880kb

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: 1ms
memory: 8076kb

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: 10192kb

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
44 9
94 44
32 94
38 32
62 38
68 62
89 68
97 89
76 97
54 76
96 54
16 96
78 16
25 78
33 25
58 33
24 58
56 24
35 56
53 35
36 53
57 36
79 57
66 79
8 66
13 91
37 13
42 37
85 42
19 85
90 19
7 90
15 7
65 15
46 65
14 46
86 14
39 86
27 39
4 27
6 84
93 6
45 93
70 45
1 70
92 1
69 92
83 69
23 83
77 23
28 77
...

result:

ok correct

Test #11:

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

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
53 84
79 47
15 79
45 15
40 45
58 40
89 58
78 89
59 78
28 59
80 28
12 80
18 66
6 18
17 31
94 17
64 94
98 64
4 98
41 61
60 41
85 60
55 85
95 55
37 95
88 37
72 88
35 72
82 35
73 82
81 73
20 81
75 20
71 75
27 71
39 27
24 39
57 24
92 57
76 92
91 76
96 91
62 96
29 62
44 29
90 44
16 90
87 16
48 87
43 48...

result:

ok correct

Test #12:

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

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

result:

ok correct

Subtask #3:

score: 16
Accepted

Test #13:

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

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: 1ms
memory: 9872kb

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

result:

ok correct

Test #15:

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

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
6 20
17 6
75 17
80 75
11 80
4 11
56 4
12 56
2 12
95 23
3 95
42 3
7 42
0 7
40 79
90 40
70 90
76 70
48 76
65 48
35 65
45 35
28 45
27 28
25 27
29 25
9 29
36 9
84 36
54 84
73 54
22 73
21 22
50 21
5 50
32 5
39 32
19 39
52 19
55 52
59 55
88 59
47 88
83 47
93 83
51 93
68 51
38 68
58 38
10 58
46 10
77 46...

result:

ok correct

Test #16:

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

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
96 89
23 96
12 59
19 86
51 19
71 51
90 71
7 90
48 61
55 48
43 55
94 43
72 94
31 72
77 31
65 77
38 65
24 38
53 24
56 53
21 56
84 21
68 84
44 68
29 44
17 29
47 17
35 47
25 35
75 25
76 75
34 76
36 34
30 36
6 30
5 6
45 5
58 45
52 58
88 52
64 88
80 64
82 80
10 82
74 10
63 74
87 63
37 87
85 37
67 85
26...

result:

ok correct

Test #17:

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

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

result:

ok correct

Test #18:

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

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

result:

ok correct

Subtask #4:

score: 18
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #19:

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

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: 1ms
memory: 7772kb

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: 2ms
memory: 10040kb

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
172 187
399 172
75 399
433 75
327 433
475 327
249 475
125 249
473 333
418 473
80 261
360 80
296 360
226 296
258 226
223 258
184 223
161 184
147 161
459 147
180 459
215 180
16 215
288 16
141 288
464 141
71 464
339 71
324 339
192 324
61 192
278 61
59 278
458 59
102 458
368 102
46 368
287 46
289 28...

result:

ok correct

Test #22:

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

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 253
457 391
185 457
214 185
171 214
293 171
139 293
219 139
364 425
227 364
0 227
98 0
372 98
459 372
38 459
275 38
307 275
137 307
343 137
292 343
218 292
156 218
251 156
29 251
129 29
160 129
42 160
285 42
266 285
196 266
30 196
92 30
216 92
2 216
320 2
200 320
26 200
392 26
159 392
155 15...

result:

ok correct

Test #23:

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

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 403
313 60
300 47
70 300
150 70
158 150
440 178
479 440
442 479
253 442
131 253
164 131
392 164
340 392
176 340
235 176
89 235
341 89
212 341
254 212
186 254
171 186
103 171
196 103
183 196
361 183
404 361
396 404
342 396
202 342
449 202
379 449
419 379
433 419
338 433
0 123
269 0
346 269
39...

result:

ok correct

Test #24:

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

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
380 450
336 422
315 385
304 314
440 421
292 440
281 343
276 466
254 369
222 328
217 370
208 467
361 418
204 361
198 267
194 354
182 395
393 182
342 393
346 342
179 56
177 200
446 356
174 446
306 365
170 306
163 390
157 348
301 231
144 301
258 416
137 258
383 430
238 383
136 238
134 444
298 420
1...

result:

ok correct

Test #25:

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

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
270 270
484 488
482 483
146 481
442 473
421 162
93 450
69 441
404 413
440 386
380 440
374 394
372 452
369 456
365 388
361 464
358 100
144 416
352 494
346 461
321 129
316 403
312 273
307 299
234 304
294 431
495 301
293 495
284 478
279 385
276 490
274 276
255 384
357 340
247 357
298 393
243 31
241...

result:

ok correct

Test #26:

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

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
0 0
400 392
428 359
412 334
403 328
416 323
398 299
322 284
469 279
338 252
420 338
343 244
441 343
466 242
253 218
445 200
404 181
371 175
460 168
248 167
395 248
237 155
201 147
476 201
357 476
292 357
364 140
133 296
405 129
208 119
473 208
341 273
115 341
217 107
375 217
397 375
424 397
259 ...

result:

ok correct

Test #27:

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

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
475 257
412 83
420 412
348 420
413 348
217 413
153 217
269 0
258 269
159 258
276 159
55 276
333 55
250 333
454 250
425 454
147 425
452 147
419 452
411 419
291 411
379 291
169 379
392 169
56 392
142 56
224 142
80 224
48 80
353 48
349 353
238 349
407 238
263 407
23 263
315 23
11 315
393 11
154 393...

result:

ok correct

Subtask #5:

score: 20
Accepted

Test #28:

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

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
328 1512
694 328
1288 694
595 1288
1036 595
121 1036
1420 121
1260 1420
780 1260
330 780
442 330
991 442
1247 991
1628 1247
978 1628
1447 978
975 1447
183 975
1019 183
1493 1019
1596 1493
266 1596
1002 266
799 1002
1716 799
310 1716
1192 310
1013 1192
387 1013
734 387
1784 734
660 1784
1130 660...

result:

ok correct

Test #29:

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

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
1620 1219
1280 1620
685 1280
522 685
743 522
1141 743
951 1141
1608 951
1274 1608
930 1274
1937 930
276 1937
73 192
556 1397
1939 556
788 1939
1675 788
791 1239
1653 791
272 1653
1666 272
464 1666
1209 464
64 1209
1441 1770
1046 1441
1286 1046
319 1286
1650 319
985 1650
1465 985
1045 1465
115 1...

result:

ok correct

Test #30:

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

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 1354
1154 1139
170 1154
1314 170
1303 1314
267 1303
953 267
1401 953
426 1401
487 426
1083 487
1764 1083
460 1764
739 460
1767 739
628 1767
5 628
1048 5
1116 1048
943 900
1460 943
1377 1460
1567 1377
1614 1567
588 1614
114 588
1808 114
1186 1808
1687 1186
177 579
928 177
451 928
428 451
61...

result:

ok correct

Test #31:

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

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: 0ms
memory: 10076kb

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
1987 1828
1934 1778
1770 1753
1706 1694
1774 1587
1548 1494
1741 1455
1755 1434
1478 1415
1690 1360
1290 1473
1395 1264
1283 1258
1430 1216
1711 1430
1595 1189
1954 1184
1938 1126
1571 1068
1321 1054
1875 1017
1007 1895
1312 982
972 1733
1008 963
960 1911
1743 959
1842 946
939 1066
1747 939
1777...

result:

ok correct

Test #33:

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

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
1902 1877
1862 1854
1804 1803
1747 1741
1806 1705
1916 1621
1904 1563
1608 1546
1852 1525
1644 1439
1846 1430
1827 1846
1494 1827
1579 1425
1710 1395
1703 1322
1629 1318
1468 1292
1536 1291
1706 1290
1303 1272
1667 1265
1261 1361
1606 1246
1509 1235
1224 1730
1376 1204
1867 1195
1433 1183
1718 1...

result:

ok correct

Test #34:

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

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
0 0
1895 1870
1753 1731
1724 1679
1643 1616
1915 1614
1936 1587
1940 1936
1847 1564
1628 1561
1762 1557
1799 1542
1750 1499
1602 1750
1702 1492
1676 1489
1790 1676
1966 1478
1545 1462
1853 1457
1664 1448
1845 1418
1758 1374
1479 1362
1892 1325
1784 1321
1690 1316
1360 1275
1257 1251
1308 1201
1...

result:

ok correct

Test #35:

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

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
917 1216
923 917
739 923
1837 739
544 1837
1871 544
894 383
866 894
1120 866
1360 1120
1149 1360
156 1149
449 156
1724 449
1064 1724
122 1064
677 122
1773 677
1749 1773
890 1749
1295 890
224 1295
1189 224
736 1189
1597 736
785 1597
690 785
1335 690
369 1335
264 369
1567 264
72 1567
1214 72
1458...

result:

ok correct

Test #36:

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

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
1155 1217
1458 1155
289 1458
1749 466
1064 1749
650 1064
647 650
1401 647
1532 1401
1024 1532
915 1024
1124 915
402 1124
1640 402
1697 1640
1624 1697
989 1624
1615 989
151 1615
1275 151
1518 1275
1100 1518
10 1100
1710 10
122 1710
1739 122
1449 1739
314 1449
1263 195
175 1263
250 175
729 250
10...

result:

ok correct

Test #37:

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

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 1460
1023 1108
607 1023
586 607
1505 586
1640 1505
1116 1640
1933 1934
1844 1933
1887 1844
1890 1887
659 1890
1596 659
307 1596
1265 307
1444 1265
136 1444
750 136
1775 750
613 1775
275 613
496 1184
1506 496
102 1506
476 102
1012 476
1703 1012
1425 1703
1929 1425
423 1929
291 423
1535 291
...

result:

ok correct

Test #38:

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

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 47
1639 1853
1637 1985
1829 1663
1531 1829
1520 1596
1506 1988
1490 1570
1659 1968
1470 1659
1459 1848
1859 1789
1325 1859
1302 1785
1286 1609
1282 1793
1855 1993
1278 1855
1591 1415
1267 1591
1733 1783
1238 1733
1236 1507
1211 1331
1210 1775
1251 1201
1954 1251
1184 1700
1757 1879
1113 1757...

result:

ok correct

Test #39:

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

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
1861 1753
1970 1730
1808 1687
1843 1679
1919 1678
1771 1653
1981 1627
1640 1623
1931 1568
1660 1548
1812 1520
1768 1498
1741 1768
1879 1741
1699 1488
1460 1459
1493 1456
1661 1438
1889 1428
1566 1420
1531 1386
1755 1382
1490 1330
1938 1309
1715 1938
1352 1304
1602 1274
1280 1272
1369 1270
1268 ...

result:

ok correct

Test #40:

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

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 0
1256 564
1322 1256
723 1322
928 0
331 928
43 331
744 43
1575 744
932 1575
1847 932
782 1847
211 782
401 211
668 401
1960 668
74 1960
1701 74
1919 1701
16 1919
1804 16
50 1804
1464 50
555 1464
361 555
984 361
1010 984
1788 1010
749 1788
1709 749
1289 1709
340 1289
1583 340
1070 1583
1479 107...

result:

ok correct

Test #41:

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

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
0 0
1086 1779

result:

ok correct

Subtask #6:

score: 0
Runtime Error

Dependency #5:

100%
Accepted

Test #42:

score: 0
Runtime Error

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:

Unauthorized output

result: