QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#384945#7448. rfplcaalpha1022AC ✓1095ms8644kbC++141.7kb2024-04-10 14:03:242024-04-10 14:03:26

Judging History

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

  • [2024-04-10 14:03:26]
  • 评测
  • 测评结果:AC
  • 用时:1095ms
  • 内存:8644kb
  • [2024-04-10 14:03:24]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 4e5;
const int B = 300;
const int C = (N - 1) / B + 1;

int n, m;
int a[N + 5], pos[N + 5], anc[N + 5];
int mx[C + 5], tag[C + 5];
void build(int p) {
  int l = (p - 1) * B + 1, r = min(p * B, n - 1);
  mx[p] = 0;
  for (int i = l; i <= r; ++i) mx[p] = max(mx[p], a[i] = max(a[i] - tag[p], 0));
  tag[p] = 0;
  for (int i = l; i <= r; ++i)
    anc[i] = a[i] < l ? a[i] : anc[a[i]];
}
void update(int l, int r, int k) {
  for (int i = l; i <= min(pos[l] * B, r); ++i) a[i] = max(a[i] - k, 0);
  build(pos[l]);
  if (pos[l] == pos[r]) return ;
  for (int i = (pos[r] - 1) * B + 1; i <= r; ++i) a[i] = max(a[i] - k, 0);
  build(pos[r]);
  for (int p = pos[l] + 1; p < pos[r]; ++p) {
    int l = (p - 1) * B + 1;
    tag[p] += k;
    if (mx[p] < l) mx[p] = max(mx[p] - k, 1);
    else build(p);
  }
}
int getFa(int u) { return max(a[u] - tag[pos[u]], 0); }
int getAnc(int u) { return mx[pos[u]] <= (pos[u] - 1) * B ? getFa(u) : anc[u]; }
int query(int u, int v) {
  while (1) {
    int fu = getAnc(u), fv = getAnc(v);
    if (fu == fv) break;
    if (fu < fv) swap(u, v), swap(fu, fv);
    u = fu;
  }
  while (u != v) {
    if (u < v) swap(u, v);
    u = getFa(u);
  }
  return u;
}

int lastans;

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) scanf("%d", a + i), --a[i], pos[i] = (i - 1) / B + 1;
  for (int p = 1; p <= pos[n - 1]; ++p) build(p);
  for (; m; --m) {
    int op, x, y, z; scanf("%d%d%d", &op, &x, &y), x ^= lastans, y ^= lastans, --x, --y;
    if (op == 1) scanf("%d", &z), z ^= lastans, update(x, y, z);
    else printf("%d\n", lastans = query(x, y) + 1);
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 373ms
memory: 8584kb

input:

400000 400000
1 2 1 4 1 1 5 4 6 5 9 1 1 13 3 8 12 16 3 11 8 8 2 18 21 15 7 23 11 6 4 26 17 5 12 6 5 28 32 26 21 5 19 1 25 25 11 26 47 11 31 25 18 7 25 36 40 23 54 31 14 62 61 33 57 40 11 16 24 51 69 25 55 51 55 65 34 19 18 21 20 62 64 83 22 48 67 47 21 27 30 63 10 14 70 63 18 17 74 98 40 89 10 7 30 ...

output:

1
1
1
1
1
1
4
1
1
1
4
1
1
18
1
4
1
18
1
1
4
1
1
1
1
5
1
4
4
4
11
5
1
4
1
4
1
1
4
1
1
1
4
1
1
1
1
4
4
1
1
1
4
4
1
1
1
1
4
1
1
1
5
1
1
1
1
5
1
1
1
1
4
1
1
12
12
1
1
4
1
1
11
1
1
1
1
4
1
1
1
4
1
1
1
14
1
18
7
5
25
1
62
1
1
1
1
1
1
1
4
4
4
102
1
1
1
1
1
2
1
1
1
1
1
1
1
1
18
4
1
1
4
5
1
1
1
1
1
1
1
1
1
1...

result:

ok 200476 lines

Test #2:

score: 0
Accepted
time: 783ms
memory: 8592kb

input:

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

output:

1
1
289629
1
1
37362
1
1
1
1
1
2107
1
1
1
1
1
200528
1
1
1
1
1
1
1
1
1
11646
1
1
1
1
7608
1
1
1
1
1
12297
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
206102
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
234105
1
213107
1
1
1
1
47884
1
1
1
1
1
1
1
1
1
1
1
4725
1
1
1
2170
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
206097
1
...

result:

ok 199431 lines

Test #3:

score: 0
Accepted
time: 706ms
memory: 8596kb

input:

400000 400000
1 2 2 4 4 5 7 7 9 10 11 12 13 14 15 15 16 17 18 20 20 22 22 23 24 26 27 27 28 30 31 32 32 33 35 35 37 38 38 40 41 41 42 43 45 45 46 47 49 49 51 52 53 53 54 56 57 58 58 60 60 61 63 64 64 65 66 68 68 70 71 71 72 73 75 75 76 78 79 79 81 81 82 83 85 85 87 88 88 90 91 92 92 94 95 95 96 98 9...

output:

210801
160667
149084
223804
42542
53089
15189
225821
254995
20768
39457
47988
79032
79157
32888
132798
56834
104162
380609
81459
27942
15916
76220
122556
5183
310812
148803
188513
211433
26186
271890
236458
281943
294363
101756
132671
61499
79360
30593
172339
261927
78569
135362
217756
23629
227179
...

result:

ok 200314 lines

Test #4:

score: 0
Accepted
time: 707ms
memory: 8612kb

input:

400000 400000
1 1 3 3 1 1 6 3 1 5 9 8 4 14 15 16 17 14 13 16 14 22 14 24 20 18 21 23 22 22 22 29 32 30 29 29 36 32 32 38 36 33 38 43 44 45 45 46 48 45 45 49 48 51 49 49 48 55 51 54 52 56 61 60 61 60 65 64 66 66 62 66 69 73 66 75 71 77 77 79 75 81 79 76 85 83 86 86 82 83 83 89 87 87 90 92 97 94 94 92...

output:

66536
42746
75273
60596
395361
75345
176775
11033
45502
92873
10536
28053
95739
65423
23980
148212
148187
68177
95384
240392
167540
203213
115465
170774
55225
159774
117049
31929
63997
20775
168687
18075
230893
55461
8262
180040
126544
12538
157569
254873
43232
212315
165491
46473
21093
169898
7139
...

result:

ok 200328 lines

Test #5:

score: 0
Accepted
time: 654ms
memory: 8524kb

input:

400000 400000
1 1 1 3 3 4 6 8 8 10 10 10 12 14 14 15 15 16 17 19 21 20 22 23 24 24 26 27 27 30 31 31 32 34 33 36 35 37 38 40 39 42 41 42 44 46 45 47 49 48 50 51 51 53 53 55 57 56 59 59 60 60 63 64 63 66 65 66 67 70 69 71 71 74 75 76 77 77 79 79 80 80 83 83 85 86 86 86 88 89 91 91 92 92 94 96 96 96 9...

output:

176159
114275
14085
231014
132050
95691
93758
210575
14952
83916
274682
13907
105473
48151
155526
90678
53411
182975
221031
126955
150326
307833
68995
166787
49652
104548
236019
113064
132156
65611
85394
34656
117176
608
190709
175534
95813
174875
192078
165010
183694
208180
24346
152280
314154
2491...

result:

ok 200095 lines

Test #6:

score: 0
Accepted
time: 630ms
memory: 8528kb

input:

400000 400000
1 1 3 3 1 1 6 3 1 5 9 8 4 14 15 16 17 14 13 16 14 22 14 24 20 18 21 23 22 22 22 29 32 30 29 29 36 32 32 38 36 33 38 43 44 45 45 46 48 45 45 49 48 51 49 49 48 55 51 54 52 56 61 60 61 60 65 64 66 66 62 66 69 73 66 75 71 77 77 79 75 81 79 76 85 83 86 86 82 83 83 89 87 87 90 92 97 94 94 92...

output:

265110
56921
177951
17569
11033
64259
70004
25947
80353
54746
65423
48917
161026
68177
264589
170774
77420
31929
94829
53873
168687
18075
21563
163635
51540
224275
114283
62827
126544
288274
12538
15780
209938
155113
3981
339925
79736
195100
97468
73031
103710
91813
118003
241688
138289
66328
182956...

result:

ok 199399 lines

Test #7:

score: 0
Accepted
time: 740ms
memory: 8604kb

input:

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

output:

1
1
1
1
318434
1
1
143691
1
210125
1
1
13713
175331
1
1
1
1
1
11022
1
1
22733
1
1
210126
9546
134986
1
124872
1
103369
1
108106
42169
40449
1
1
8253
179436
142152
39135
1
121851
27988
1
1
1
63210
1
1
9626
1
1
121241
203789
1012
1
145550
1
86090
25925
1
1
95571
1
27060
197787
1
93637
200256
114145
34...

result:

ok 199398 lines

Test #8:

score: 0
Accepted
time: 803ms
memory: 8464kb

input:

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

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
187326
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 199964 lines

Test #9:

score: 0
Accepted
time: 989ms
memory: 8604kb

input:

400000 400000
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 9...

output:

91
82
94
91
93
52
45
29
31
36
27
59
19
17
64
1
1
1
1
1
1
1
29
1
1
1
1
1
41
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
22
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
115623
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
133037
1
1
1
1
1
1
1
47
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 40000 lines

Test #10:

score: 0
Accepted
time: 1035ms
memory: 8612kb

input:

400000 400000
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 9...

output:

191
182
178
165
185
162
173
166
165
127
127
168
137
144
64
131
105
115
37
61
168
168
29
54
112
1
133
1
41
121
141
81
95
65
1
35
1
86
1
1
129
1
61
1
1
123
1
1
22
1
1
1
1
1
1
1
1
1
1
1
103
1
1
1
1
1
115623
1
1
1
1
1
1
1
1
1
1
1
71
1
1
1
1
1
133037
1
1
1
1
1
1
1
47
1
1
1
1
1
1
1
1
1
1
1
68
1
1
1
1
1
1
...

result:

ok 40000 lines

Test #11:

score: 0
Accepted
time: 1090ms
memory: 8644kb

input:

400000 400000
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 9...

output:

291
291
290
276
277
272
237
239
247
218
227
277
187
271
200
176
259
278
143
242
168
168
237
138
112
178
133
252
41
121
141
81
95
65
1
35
1
86
1
136
129
177
61
120
1
123
1
1
22
180
186
1
1
1
1
107
1
1
1
65
103
1
21
1
1
1
115623
115
1
1
1
1
1
1
1
1
1
1
71
1
1
1
1
1
133037
1
1
1
1
1
1
1
47
1
1
1
1
1
1
...

result:

ok 40000 lines

Test #12:

score: 0
Accepted
time: 450ms
memory: 8604kb

input:

400000 400000
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 9...

output:

195546
142231
188299
113064
129034
107442
113059
87306
63779
71726
131225
91431
101847
18176
36879
45704
67500
24079
24080
46574
24079
24079
24079
158137
24080
53649
52451
24079
99
24080
24079
52451
52450
24079
24079
24079
24080
1435
24079
1345
1347
1344
1344
1346
86326
1345
1345
257181
98837
1345
1...

result:

ok 200482 lines

Test #13:

score: 0
Accepted
time: 972ms
memory: 8592kb

input:

400000 400000
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 9...

output:

391
386
374
387
369
345
365
385
329
309
327
291
305
285
336
276
259
278
315
242
358
367
237
271
338
178
377
252
303
149
141
370
131
190
316
150
167
86
337
136
129
177
61
120
123
123
249
252
22
180
186
1
1
1
88
107
165
104
1
65
103
340
21
1
45
1
115623
115
1
1
1
1
1
1
1
1
1
1
71
266
14
1
1
1
133037
1...

result:

ok 40000 lines

Test #14:

score: 0
Accepted
time: 1061ms
memory: 8528kb

input:

400000 400000
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 9...

output:

491
481
486
463
461
455
441
458
441
420
427
400
423
398
371
421
413
441
381
423
358
367
445
355
338
413
377
252
303
392
421
370
393
372
316
360
167
157
337
216
131
177
193
120
123
123
249
252
97
180
186
401
29
316
88
107
165
104
287
65
103
340
21
1
45
1
115623
115
153
226
1
146
1
1
1
1
1
1
71
266
14...

result:

ok 40000 lines

Test #15:

score: 0
Accepted
time: 1095ms
memory: 8584kb

input:

400000 400000
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 9...

output:

591
581
573
572
557
547
557
531
523
511
527
495
491
525
472
466
567
441
487
423
548
566
445
488
564
413
377
505
565
392
421
370
393
372
316
360
318
429
337
497
499
237
449
246
375
538
249
252
464
180
186
401
473
316
324
107
165
104
287
65
103
340
205
488
45
75
115623
115
153
226
1
146
1
1
1
1
1
423
...

result:

ok 40000 lines

Test #16:

score: 0
Accepted
time: 983ms
memory: 8616kb

input:

400000 400000
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 9...

output:

691
690
682
683
691
657
685
677
657
673
627
604
609
652
608
566
567
604
553
604
548
566
653
488
564
648
621
505
565
663
421
659
429
497
632
475
501
429
365
497
499
556
449
517
375
538
365
360
464
631
245
401
473
316
324
253
335
326
287
220
653
340
205
488
386
574
115623
115
153
226
310
146
373
610
2...

result:

ok 40000 lines

Test #17:

score: 0
Accepted
time: 307ms
memory: 4956kb

input:

100000 100000
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 9...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 100000 lines

Test #18:

score: 0
Accepted
time: 740ms
memory: 8472kb

input:

400000 400000
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 9...

output:

30464
209869
346131
58298
87306
91431
324429
335615
71727
272855
203724
126725
49227
324366
262038
263155
69277
97745
86853
114040
24040
218806
101585
41582
26712
76484
209740
270655
126128
247387
100189
276196
154229
73723
211621
4636
192962
258268
116999
230952
258737
229156
110595
65655
92774
783...

result:

ok 200202 lines

Test #19:

score: 0
Accepted
time: 374ms
memory: 8640kb

input:

400000 400000
1 2 1 4 1 1 5 4 6 5 9 1 1 13 3 8 12 16 3 11 8 8 2 18 21 15 7 23 11 6 4 26 17 5 12 6 5 28 32 26 21 5 19 1 25 25 11 26 47 11 31 25 18 7 25 36 40 23 54 31 14 62 61 33 57 40 11 16 24 51 69 25 55 51 55 65 34 19 18 21 20 62 64 83 22 48 67 47 21 27 30 63 10 14 70 63 18 17 74 98 40 89 10 7 30 ...

output:

1
1
1
1
4
4
1
1
1
1
1
1
1
1
274
1
1
1
1
1
1
4
1
5
1
1
1
4
4
1
40
1
1
4
1
1
1
4
1
4
1
1
4
1
8
1
4
1
5
4
1
5
1
4
1
4
1
1
1
1
7
183
4
1
1
1
1
1
4
4
5
4
4
18
4
1
12
1
1
1
4
4
1
5
1
1
1
1
4
5
4
23
4
1
1
11
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
4
1
5
1
1
1
1
4
127
1
1
4
4
1
4
1
1
4
1
12
11
12
1
4
1
1
1
...

result:

ok 199826 lines

Test #20:

score: 0
Accepted
time: 354ms
memory: 8600kb

input:

400000 400000
1 2 1 4 1 1 5 4 6 5 9 1 1 13 3 8 12 16 3 11 8 8 2 18 21 15 7 23 11 6 4 26 17 5 12 6 5 28 32 26 21 5 19 1 25 25 11 26 47 11 31 25 18 7 25 36 40 23 54 31 14 62 61 33 57 40 11 16 24 51 69 25 55 51 55 65 34 19 18 21 20 62 64 83 22 48 67 47 21 27 30 63 10 14 70 63 18 17 74 98 40 89 10 7 30 ...

output:

1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 200476 lines

Test #21:

score: 0
Accepted
time: 716ms
memory: 8600kb

input:

400000 400000
1 1 1 3 3 4 6 8 8 10 10 10 12 14 14 15 15 16 17 19 21 20 22 23 24 24 26 27 27 30 31 31 32 34 33 36 35 37 38 40 39 42 41 42 44 46 45 47 49 48 50 51 51 53 53 55 57 56 59 59 60 60 63 64 63 66 65 66 67 70 69 71 71 74 75 76 77 77 79 79 80 80 83 83 85 86 86 86 88 89 91 91 92 92 94 96 96 96 9...

output:

101073
211829
326427
107757
119987
176159
10989
282713
87073
14085
231008
132050
19163
46545
84563
71799
58338
257776
185047
88731
17459
90678
196587
69916
179292
42914
323586
52162
140364
228808
180551
125544
68711
113064
152699
231292
192479
39818
14221
237320
85394
34656
40186
117176
20260
147942...

result:

ok 200289 lines

Test #22:

score: 0
Accepted
time: 666ms
memory: 8520kb

input:

400000 400000
1 2 2 4 4 5 7 7 9 10 11 12 13 14 15 15 16 17 18 20 20 22 22 23 24 26 27 27 28 30 31 32 32 33 35 35 37 38 38 40 41 41 42 43 45 45 46 47 49 49 51 52 53 53 54 56 57 58 58 60 60 61 63 64 64 65 66 68 68 70 71 71 72 73 75 75 76 78 79 79 81 81 82 83 85 85 87 88 88 90 91 92 92 94 95 95 96 98 9...

output:

161262
3721
42542
15189
362730
214568
116266
311821
351437
24200
63424
56834
104162
209382
15916
232797
232733
178403
620
257291
236002
305819
257291
132671
314616
30593
261930
147
164897
68758
153842
229733
61550
74335
162103
215815
252933
221564
91911
126631
233858
183265
155428
313622
20954
94438...

result:

ok 199414 lines

Test #23:

score: 0
Accepted
time: 752ms
memory: 8548kb

input:

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

output:

1
210416
7885
1
216008
36186
146716
1
1
217702
183830
1
213656
1
1
232671
1
1
1
173279
163087
1
69971
100996
1
1
1
1
1
1
1
1
1
71396
1
1
1
1
1
1
1
1
160231
131210
1
1
161995
1
1
1
1
200543
1
10552
1
1
1
16813
1
1
1
1
1
1
1
1
1
1
1
1
1
45381
1
1
1
148081
102158
1
1
1
1
1
103798
1
177666
40784
203246
...

result:

ok 200064 lines