QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75930#5216. 汉诺塔hutality100 ✓537ms57112kbC++115.1kb2023-02-06 17:44:542023-02-06 17:44:55

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 201ms
memory: 57068kb

input:

10000
3 1
1
1
1
1 1
1
2 1
1
1
4 1
1
1
1
1
1 1
1
2 1
1
1
4 1
1
1
1
1
5 1
1
1
1
1
1
5 1
1
1
1
1
1
4 1
1
1
1
1
1 1
1
3 1
1
1
1
1 1
1
4 1
1
1
1
1
5 1
1
1
1
1
1
4 1
1
1
1
1
4 1
1
1
1
1
1 1
1
3 1
1
1
1
4 1
1
1
1
1
4 1
1
1
1
1
2 1
1
1
5 1
1
1
1
1
1
3 1
1
1
1
5 1
1
1
1
1
1
1 1
1
2 1
1
1
2 1
1
1
3 1
1
1
1
5 ...

output:

7
1
3
15
1
3
15
31
31
15
1
7
1
15
31
15
15
1
7
15
15
3
31
7
31
1
3
3
7
31
7
31
15
7
7
7
3
31
31
7
7
1
7
1
7
15
15
3
3
3
1
7
1
15
3
15
1
7
31
31
7
3
7
31
31
7
1
7
3
7
3
1
31
15
1
31
15
31
7
1
31
3
15
3
15
15
3
7
7
31
7
1
1
31
3
1
3
3
1
1
7
7
15
15
15
31
7
7
3
7
3
3
31
15
31
1
15
7
15
31
1
3
31
7
7
1
...

result:

ok 10000 numbers

Test #2:

score: 10
Accepted
time: 230ms
memory: 57112kb

input:

10000
4 2
2 1
1 2
1 2
2 1
2 2
2 1
2 1
3 2
1 2
1 2
1 2
1 2
2 1
2 2
2 1
2 1
2 2
1 2
2 1
2 2
1 2
1 2
3 2
2 1
1 2
1 2
1 2
2 1
1 2
2 1
4 2
2 1
2 1
1 2
1 2
3 2
1 2
1 2
1 2
5 2
2 1
1 2
1 2
2 1
2 1
3 2
2 1
1 2
2 1
4 2
2 1
2 1
2 1
2 1
2 2
1 2
1 2
2 2
1 2
1 2
1 2
1 2
3 2
1 2
2 1
1 2
2 2
2 1
2 1
3 2
1 2
1 2
1 ...

output:

31
7
27
2
7
10
11
14
2
2
43
27
66
15
39
11
11
3
22
7
27
3
102
59
6
63
19
58
34
55
54
6
11
11
2
10
114
55
2
3
19
22
30
71
27
47
18
3
27
10
107
103
23
7
3
2
111
10
35
34
10
55
34
47
3
2
3
3
3
7
83
3
94
3
22
19
66
43
54
7
3
3
2
10
123
27
23
7
110
31
74
39
11
3
3
39
82
11
11
10
50
7
6
11
7
47
35
3
6
2
2...

result:

ok 10000 numbers

Test #3:

score: 10
Accepted
time: 206ms
memory: 56992kb

input:

10000
3 2
2 1
2 1
1 2
2 2
2 1
1 2
5 2
1 2
2 1
1 2
1 2
2 1
2 2
2 1
1 2
2 2
1 2
1 2
1 2
2 1
5 2
1 2
2 1
1 2
1 2
2 1
4 2
1 2
2 1
1 2
2 1
5 2
2 1
2 1
1 2
1 2
1 2
4 2
2 1
1 2
2 1
2 1
2 2
2 1
1 2
1 2
1 2
5 2
2 1
1 2
2 1
1 2
2 1
1 2
1 2
1 2
1 2
5 2
1 2
2 1
2 1
1 2
1 2
5 2
2 1
1 2
2 1
1 2
2 1
5 2
1 2
2 1
2 ...

output:

19
6
95
6
11
2
95
47
91
34
6
3
74
3
3
107
74
102
3
119
118
11
6
86
26
2
2
51
75
3
11
98
2
82
27
42
11
22
3
87
15
2
51
3
3
118
7
2
2
6
3
106
59
22
27
6
3
14
39
11
122
55
14
10
86
14
2
35
87
82
7
11
27
35
23
19
3
11
6
7
19
2
22
19
22
70
3
6
26
7
119
42
110
47
31
42
58
46
2
43
6
86
7
11
63
11
22
43
86
...

result:

ok 10000 numbers

Test #4:

score: 10
Accepted
time: 219ms
memory: 56536kb

input:

10000
5 2
1 2
1 2
1 2
1 2
1 2
4 2
2 1
2 1
2 1
2 1
3 2
2 1
2 1
1 2
3 2
2 1
2 1
2 1
3 2
2 1
2 1
1 2
1 2
2 1
1 2
2 1
1 2
2 1
4 2
1 2
1 2
2 1
2 1
1 2
2 1
2 2
2 1
1 2
2 2
1 2
1 2
2 2
1 2
1 2
4 2
2 1
1 2
2 1
2 1
3 2
1 2
2 1
2 1
5 2
1 2
1 2
1 2
1 2
2 1
5 2
1 2
1 2
1 2
2 1
2 1
4 2
1 2
2 1
1 2
2 1
1 2
1 2
1 ...

output:

123
39
19
18
19
2
2
2
55
2
6
11
11
34
23
122
119
47
3
3
110
3
75
23
10
59
87
47
11
55
31
30
59
35
2
11
26
22
2
31
31
11
71
38
42
7
58
7
14
15
99
11
102
18
2
46
7
3
3
47
38
58
7
19
22
15
106
23
26
30
6
50
87
6
3
30
71
19
119
3
6
46
10
102
115
3
50
38
10
11
7
118
119
19
2
106
10
3
63
51
7
2
110
30
15
...

result:

ok 10000 numbers

Test #5:

score: 10
Accepted
time: 244ms
memory: 54884kb

input:

10000
4 3
3 2 1
1 3 2
1 3 2
2 1 3
5 3
1 2 3
2 1 3
3 2 1
3 2 1
2 1 3
4 3
1 2 3
1 2 3
1 2 3
3 2 1
4 3
3 1 2
1 3 2
1 2 3
3 2 1
5 3
2 3 1
3 1 2
3 2 1
2 3 1
1 3 2
1 3
2 3 1
5 3
1 3 2
1 2 3
1 3 2
2 1 3
1 3 2
2 3
3 1 2
3 2 1
1 3
3 2 1
5 3
2 1 3
2 3 1
1 2 3
2 1 3
3 2 1
5 3
3 2 1
3 1 2
3 1 2
1 2 3
1 2 3
1 3
...

output:

74
197
87
111
249
4
284
19
3
237
155
6
16
212
18
43
205
4
3
50
17
10
49
60
235
10
17
242
10
5
4
6
133
41
97
4
17
42
142
19
18
213
17
255
41
4
10
110
302
97
74
4
10
247
10
109
4
16
212
213
4
249
247
3
213
42
250
229
61
19
61
109
19
50
60
42
248
6
10
4
30
17
115
91
164
40
18
4
4
3
5
4
49
89
212
4
248
...

result:

ok 10000 numbers

Test #6:

score: 10
Accepted
time: 249ms
memory: 56976kb

input:

10000
3 3
1 3 2
2 1 3
1 2 3
1 3
3 1 2
1 3
2 3 1
4 3
3 1 2
1 3 2
3 2 1
2 1 3
3 3
2 3 1
1 2 3
1 3 2
3 3
3 1 2
3 2 1
2 3 1
3 3
3 2 1
3 1 2
2 3 1
1 3
2 3 1
2 3
2 1 3
1 3 2
4 3
1 2 3
3 1 2
3 1 2
3 1 2
3 3
1 3 2
1 3 2
1 2 3
3 3
1 3 2
3 2 1
1 2 3
3 3
2 1 3
1 2 3
1 3 2
5 3
1 2 3
1 3 2
3 1 2
3 2 1
1 3 2
2 3
...

output:

59
4
4
116
42
48
29
4
17
97
59
52
41
210
15
115
48
4
31
10
97
212
205
236
49
5
4
66
95
16
120
90
297
41
17
22
16
19
4
117
18
303
6
3
17
4
4
4
304
41
9
18
167
18
4
94
72
10
116
110
113
31
82
29
18
6
22
172
143
110
4
109
16
117
5
3
116
60
197
96
3
16
3
18
116
5
3
48
264
70
4
18
230
22
17
4
229
49
48
4...

result:

ok 10000 numbers

Test #7:

score: 10
Accepted
time: 250ms
memory: 56980kb

input:

10000
3 3
1 3 2
1 3 2
3 2 1
4 3
2 1 3
3 1 2
2 3 1
3 1 2
5 3
2 3 1
2 1 3
3 1 2
2 3 1
3 1 2
5 3
2 3 1
3 2 1
2 3 1
2 1 3
1 3 2
5 3
3 2 1
2 1 3
3 2 1
1 2 3
3 1 2
3 3
2 1 3
3 2 1
3 1 2
5 3
2 3 1
2 3 1
3 1 2
1 2 3
2 3 1
5 3
1 3 2
1 3 2
2 1 3
1 3 2
3 1 2
4 3
3 2 1
1 2 3
1 2 3
1 3 2
1 3
3 1 2
4 3
1 3 2
3 2 ...

output:

61
115
256
238
156
47
248
304
46
4
121
24
4
246
3
51
3
108
116
18
4
132
50
5
110
5
211
49
16
133
19
6
170
90
162
43
17
4
18
213
254
110
22
121
3
30
53
109
3
22
116
41
23
4
29
28
3
215
17
34
6
48
4
59
116
4
64
17
212
17
23
118
6
3
115
50
237
49
43
10
15
6
47
249
23
23
39
49
17
15
65
22
3
97
214
54
4
...

result:

ok 10000 numbers

Test #8:

score: 10
Accepted
time: 537ms
memory: 55116kb

input:

10000
3 4
1 3 4 2
1 2 3 4
1 4 3 2
2 4
3 2 1 4
2 1 3 4
3 4
2 3 1 4
4 2 1 3
2 1 3 4
4 4
3 2 4 1
2 4 1 3
1 2 4 3
3 4 1 2
3 4
2 3 4 1
4 2 3 1
2 3 4 1
2 4
2 1 4 3
4 1 3 2
4 4
3 2 4 1
2 4 3 1
4 3 1 2
2 4 1 3
5 4
2 1 4 3
2 3 4 1
4 2 3 1
2 3 1 4
1 2 3 4
2 4
4 1 2 3
2 1 3 4
4 4
1 2 4 3
4 1 2 3
3 2 4 1
4 1 3 ...

output:

82
22
82
219
77
29
194
436
24
193
159
90
67
93
204
7
146
35
403
445
207
64
79
30
95
24
201
66
91
401
24
29
152
72
190
77
207
91
218
6
438
25
152
28
203
5
98
6
6
206
404
42
200
198
5
30
7
430
84
5
30
195
176
8
160
7
33
14
445
26
214
6
6
568
23
6
205
198
207
211
219
5
200
351
6
184
103
76
80
31
5
350
...

result:

ok 10000 numbers

Test #9:

score: 10
Accepted
time: 473ms
memory: 54984kb

input:

10000
3 4
3 2 4 1
4 2 3 1
1 4 3 2
5 4
3 4 2 1
1 2 3 4
1 3 4 2
4 1 2 3
1 3 4 2
3 4
2 4 3 1
3 1 2 4
1 2 4 3
3 4
3 1 4 2
4 2 1 3
4 2 1 3
5 4
1 3 4 2
3 4 1 2
4 1 3 2
2 3 1 4
4 1 3 2
3 4
2 4 1 3
4 2 3 1
3 1 4 2
1 4
2 4 1 3
5 4
1 2 3 4
2 4 1 3
1 4 3 2
3 2 1 4
4 3 2 1
4 4
2 3 4 1
4 3 1 2
1 3 2 4
3 2 1 4
1 ...

output:

80
295
85
106
509
108
7
369
160
6
30
23
28
5
21
446
66
8
77
25
8
77
254
6
30
78
25
9
426
67
78
69
7
299
404
33
6
56
381
95
7
157
80
232
196
22
6
6
415
25
67
87
344
433
418
450
188
6
203
62
385
169
257
159
278
205
411
184
66
445
189
511
490
5
354
198
90
37
430
210
406
393
537
167
386
421
23
495
258
4...

result:

ok 10000 numbers

Test #10:

score: 10
Accepted
time: 515ms
memory: 55024kb

input:

10000
2 4
4 1 2 3
4 2 1 3
1 4
1 4 3 2
4 4
3 1 4 2
2 3 4 1
2 3 4 1
4 3 1 2
5 4
3 4 2 1
1 4 3 2
1 2 4 3
2 3 4 1
2 1 4 3
5 4
3 2 4 1
2 1 4 3
3 4 1 2
3 2 1 4
4 1 3 2
5 4
4 2 3 1
4 3 2 1
3 4 2 1
1 3 2 4
2 4 3 1
1 4
3 4 2 1
1 4
2 1 3 4
2 4
2 4 1 3
2 4 1 3
2 4
3 4 2 1
3 2 1 4
2 4
2 4 3 1
1 2 4 3
3 4
2 1 4 ...

output:

25
9
242
342
444
347
5
6
38
24
30
80
8
362
194
170
8
8
64
7
374
34
274
193
32
8
202
207
431
28
139
442
194
486
83
144
522
529
485
32
6
447
37
105
247
7
94
5
5
84
40
155
563
8
14
22
520
5
261
474
218
169
24
259
80
188
15
8
83
186
71
25
414
5
103
6
71
28
6
24
325
260
27
77
349
204
7
174
30
245
85
5
46...

result:

ok 10000 numbers

Extra Test:

score: 0
Extra Test Passed