QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190115#6759. 字符串Dualqwq20 383ms26308kbC++233.3kb2023-09-28 11:48:362023-09-28 11:48:37

Judging History

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

  • [2023-09-28 11:48:37]
  • 评测
  • 测评结果:20
  • 用时:383ms
  • 内存:26308kb
  • [2023-09-28 11:48:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n,q;
char s[N],ss[N];
int v1[N],v2[N],ton[N],sa[N];
int rk[N];
inline int Rev(int x) { return n + n + 2 - x;}
inline bool cmp(int *r,int i,int j,int k) {
	return r[i] == r[j] && (i + k > n ? 0 : r[i + k]) == (j + k > n ? 0 : r[j + k]);
}
inline void GetSa(char *s,int *sa,int n,int m) {
	#define For(i,a,b) for(int i = (a);i <= (b);i++)
	#define Rof(i,a,b) for(int i = (a);i >= (b);i--) 
	int *x = v1,*y = v2,*t;
	For(i,1,m) ton[i] = 0;
	For(i,1,n) ton[x[i] = s[i]]++;
	For(i,1,m) ton[i] += ton[i - 1];
	Rof(i,n,1) sa[ton[x[i]]--] = i;
	for(int j = 1,p;j <= n;j *= 2,m = p) {
		p = 0;
		For(i,n - j + 1,n) y[++p] = i;
		For(i,1,n) if(sa[i] > j) y[++p] = sa[i] - j;
		For(i,1,m) ton[i] = 0;
		For(i,1,n) ton[x[i]]++;
		For(i,1,m) ton[i] += ton[i - 1];
		Rof(i,n,1) sa[ton[x[y[i]]]--] = y[i],y[i] = 0;
		t = x;x = y;y = t;p = 1;x[sa[1]] = 1;
		For(i,2,n) x[sa[i]] = cmp(y,sa[i - 1],sa[i],j) ? p : (++p);
		if(p >= n) break;
	}
}
int R[N]; // 以 i 为较右回文中心的最长偶回文串
inline void Manacher() {
	int l = 0,r = 0;
	for(int i = 1;i <= n;i++) {
		if(i < r) R[i] = min(R[2 * l - i],r - i); else R[i] = 0;
		while(i + R[i] <= n && i - 1 - R[i] > 0 && s[i + R[i]] == s[i - 1 - R[i]])
			++R[i];
		if(i + R[i] > r) l = i,r = i + R[i];
	}
}
int ans[N];
struct BIT {
	int tr[N];
	#define lowbit(x) (x&(-x))
	inline void Clr() { for(int i = 0;i <= n + n + 2;i++) tr[i] = 0;}
	inline void upd(int x,int v) { for(int i = x;i <= n + n + 2;i += lowbit(i)) tr[i] += v;}
	inline int Sum(int x) { int res = 0;for(int i = x;i;i ^= lowbit(i)) res += tr[i];return res;}
} T[2];
struct Event {
	int lim,id,op; 
	Event(){}
	Event(const int _lim,const int _id,const int _op):
		lim(_lim),id(_id),op(_op){}
};
vector<Event> Qs[N];
int Qi[N],Qr[N];
inline void Main() {
	scanf("%d%d",&n,&q);
	scanf("%s",s + 1);
	s[n + 1] = '#';
	for(int i = 1;i <= n;i++) ss[n + n + 2 - i] = ss[i] = s[i];
	Manacher();
	GetSa(ss,sa,n + n + 1,256);
	for(int i = 1;i <= n + n + 1;i++) rk[sa[i]] = i;
	// printf("rk: ");for(int i = 1;i <= n;i++) printf("%d ",rk[i]);printf("\n");
	// printf("rkR: ");for(int i = 1;i <= n;i++) printf("%d ",rk[Rev(i)]);printf("\n");
	// printf("R:");for(int i = 1;i <= n;i++) printf("%d ",R[i]);printf("\n");
	for(int i = 1;i <= n;i++) Qs[i].clear();
	for(int i = 1;i <= q;i++) 
		scanf("%d%d",&Qi[i],&Qr[i]),ans[i] = 0;
	for(int i = 1;i <= q;i++) {
		Qs[Qi[i]].emplace_back(rk[Qi[i]],i,1);
		Qs[Qi[i] + 2 * Qr[i]].emplace_back(rk[Qi[i]],i,-1);
	}
	T[0].Clr();T[1].Clr();
	for(int i = n;i >= 1;i--) {
		T[i & 1].upd(rk[Rev(i)],1);
		for(auto it : Qs[i]) 
			ans[it.id] += it.op * (T[(i-1)&1].Sum(n + n + 2) - T[(i-1)&1].Sum(it.lim));
	}	
	for(int i = 1;i <= n;i++) Qs[i].clear();
	T[0].Clr();
	for(int i = 1;i <= q;i++) {
		Qs[Qi[i] + 1].emplace_back(Qi[i],i,-1);
		Qs[Qi[i] + Qr[i] + 1].emplace_back(Qi[i],i,1);
	}
	for(int i = n;i >= 2;i--) {
		if(rk[i] < rk[Rev(i - 1)] && R[i])
			T[0].upd(i - R[i],1);
		for(auto it : Qs[i])
			ans[it.id] += it.op * (T[0].Sum(it.lim));
	}
	for(int i = 1;i <= q;i++)
		cout << ans[i] << endl;
}
int main() {
	int SubId,T;
	scanf("%d%d",&SubId,&T);
	while(T--) Main();
	return 0;
}
/*
0 2
9 3
abacababa
1 4
2 4
3 3
9 3
abaabaaba
1 4
2 4
3 3
*/

详细

Test #1:

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

input:

1 5
5 5
aaaaa
4 1
2 1
2 2
2 2
4 1
5 5
abaab
1 1
1 2
2 1
3 1
1 1
5 5
baaaa
1 2
2 2
2 2
2 1
2 2
5 5
babab
1 2
2 2
4 1
2 2
2 2
5 5
baaab
2 2
2 1
1 1
1 2
2 2

output:

0
0
0
0
0
1
1
0
0
1
0
0
0
0
0
0
2
1
2
2
1
0
0
0
1

result:

ok 25 numbers

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 13656kb

input:

2 5
10 10
babbbbbaaa
1 4
9 1
6 2
2 3
2 1
1 5
1 5
4 2
1 2
2 4
10 10
baabbaabab
1 5
2 4
2 4
2 3
3 4
5 3
2 3
1 5
3 1
4 1
10 10
aaaaabaabb
1 5
6 2
3 2
2 2
1 1
5 1
1 5
1 5
1 4
3 3
10 10
babbaababb
5 3
7 1
7 2
1 4
6 1
4 2
2 4
2 4
4 1
1 5
10 10
babbbaabba
2 3
1 5
6 2
2 4
1 5
4 1
2 3
5 2
2 3
1 5

output:

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

result:

wrong answer 21st numbers differ - expected: '3', found: '4'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 16040kb

input:

3 5
19 19
baaababbbbbaaabbbaa
13 1
1 7
7 6
10 2
4 5
18 1
16 1
7 6
6 5
6 5
3 8
4 7
6 3
2 8
14 3
11 4
11 3
1 4
1 9
19 19
bbaababbaaaaababbba
9 1
10 4
16 1
1 9
4 6
5 4
15 1
1 7
2 6
5 7
14 3
1 9
11 3
1 7
8 6
2 8
10 1
2 8
8 2
20 19
baabaaabaabaaaababba
3 7
1 8
4 5
14 2
7 7
1 5
1 8
15 2
2 8
2 6
3 5
2 4
6 ...

output:

1
2
2
0
4
0
0
2
4
4
8
6
3
7
2
1
1
1
3
0
2
1
3
4
1
1
2
1
4
1
3
2
2
1
2
0
2
0
4
2
1
2
4
1
2
2
7
5
3
3
4
3
6
2
5
5
3
7
1
7
2
2
1
2
0
0
3
5
5
1
6
2
4
3
1
0
6
1
0
4
8
0
0
1
4
0
4
1
1
8
1
8
4
0
0
2

result:

wrong answer 1st numbers differ - expected: '0', found: '1'

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 15928kb

input:

4 5
46 50
abababbbbbbbbbabaabaaababbaaaaabababbababaaaaa
1 13
19 1
7 19
22 7
3 21
3 17
3 21
31 6
1 23
11 4
19 11
4 17
2 21
7 20
10 8
25 9
9 19
6 4
7 18
5 4
2 1
12 9
6 20
17 13
7 1
9 17
1 21
12 6
11 11
1 23
5 16
28 6
4 17
10 2
3 19
34 5
21 13
1 23
13 6
31 5
6 20
4 20
3 21
16 1
1 21
17 2
2 19
23 4
1 7...

output:

11
0
1
5
16
13
16
5
17
0
4
8
10
1
0
0
1
1
1
4
0
0
2
12
0
1
17
0
1
17
12
4
8
0
15
2
13
17
0
5
2
10
16
0
17
1
9
1
7
10
10
7
5
17
9
0
16
0
2
13
1
9
14
9
1
14
6
0
9
15
13
9
7
1
0
4
15
5
10
10
3
2
6
1
15
3
1
18
1
11
10
3
13
0
2
1
14
0
3
1
6
0
12
8
4
9
9
16
8
1
17
16
19
4
11
5
9
11
1
11
1
1
13
19
6
1
5
6
...

result:

wrong answer 1st numbers differ - expected: '9', found: '11'

Test #5:

score: 0
Wrong Answer
time: 0ms
memory: 15868kb

input:

5 5
97 98
bbaabaabbababaaaababaabababaabaababbbbbbaababaabaaabbaabbabaabbaababbabbbbbaababbbbabbbbbbbaaaaab
71 13
77 7
13 3
14 40
18 21
13 38
20 18
2 48
30 27
84 4
3 34
4 15
18 36
55 20
3 44
9 36
10 24
15 8
55 15
48 6
38 18
30 16
19 7
4 47
76 4
36 28
3 38
7 43
13 3
7 22
55 12
9 22
26 17
30 23
24 31
...

output:

5
7
0
38
11
18
9
27
15
4
33
11
21
17
43
16
17
7
13
3
5
8
4
35
3
11
37
37
0
16
10
8
12
13
24
9
0
0
6
5
16
12
16
21
2
19
4
28
3
10
7
9
32
16
26
8
9
13
27
1
23
0
20
28
35
20
45
4
11
20
11
32
1
1
28
1
1
23
31
19
43
0
10
17
3
20
34
6
16
1
33
3
6
7
21
37
9
21
9
18
1
17
6
16
0
10
11
4
10
20
8
15
6
34
18
32...

result:

wrong answer 1st numbers differ - expected: '1', found: '5'

Test #6:

score: 0
Wrong Answer
time: 7ms
memory: 16152kb

input:

6 5
998 992
bibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbabbbaabpaapbaabbbabobabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbbbbaabpaapbaabbbbbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabobabbbaabpaapbaabbbabbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabf...

output:

61
51
72
109
368
189
241
260
450
359
119
358
172
177
174
152
216
19
204
435
148
52
256
27
14
182
158
219
6
84
328
62
2
202
51
51
153
18
4
222
147
274
15
59
204
131
4
437
197
44
70
96
145
83
100
266
325
41
17
236
402
97
71
110
322
116
200
323
216
141
124
120
263
8
14
110
406
318
438
8
420
13
16
64
12...

result:

wrong answer 1st numbers differ - expected: '32', found: '61'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 16148kb

input:

7 5
1988 1997
bvappavbbaabavavpavbbaabbvappavbbaabbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbaabbvappavbbaabbvappavabaabbvappavbbaaqbvappavbbaabbpappavbqaabbvappavbbaabavappavbbaabbvappavbbapbbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbpabbvappavbba...

output:

110
305
465
412
127
82
676
796
525
184
191
178
634
14
222
841
154
122
390
436
43
150
138
152
241
17
87
303
66
356
138
200
141
76
132
179
626
848
519
157
23
178
221
58
539
96
151
172
77
70
540
38
6
225
747
218
315
323
114
458
134
282
436
155
671
89
60
104
815
28
47
8
65
229
660
121
30
774
106
501
326...

result:

wrong answer 1st numbers differ - expected: '20', found: '110'

Test #8:

score: 0
Wrong Answer
time: 7ms
memory: 16368kb

input:

8 5
2977 2978
aabaaaabaabaaaabaabaaaabaabnaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaanbaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaa...

output:

604
466
1408
0
533
1086
339
744
173
402
532
1134
416
728
194
1350
747
1423
1181
1041
98
400
1207
1263
362
1359
940
56
614
1099
98
766
266
1028
59
725
16
28
996
205
1072
706
273
859
558
16
455
264
90
1255
1233
550
0
642
514
951
1197
441
262
168
864
847
291
180
584
53
1219
376
1214
930
1146
151
422
24...

result:

wrong answer 1st numbers differ - expected: '465', found: '604'

Test #9:

score: 0
Wrong Answer
time: 8ms
memory: 14432kb

input:

9 5
3992 3963
baaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambbabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbabbmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabma...

output:

358
284
424
903
21
1063
701
1141
1931
1853
110
461
1500
1929
604
22
358
366
380
573
104
1440
18
377
342
1063
555
82
1531
1206
222
5
766
859
762
821
568
88
362
806
912
668
1815
188
389
439
41
917
244
236
83
148
1355
154
1002
513
903
881
810
67
1605
1650
7
93
175
19
472
926
1277
839
1451
266
212
119
1...

result:

wrong answer 1st numbers differ - expected: '336', found: '358'

Test #10:

score: 0
Wrong Answer
time: 68ms
memory: 16520kb

input:

10 5
21773 22026
babaaababbabbbbbaababbababaabbababbabbbbabaaaaabaabbabbbbbbaaaabaababbbabbbbbabaababbaababbbbaaabaabbaaaabbbbaaaabbbbbabaaaaaaaabbabbabbaabbbbabbbaaabbabbabababbaabaabbaabbaaaaabaabaababaabbaaaaaabababbaabbababaabbabbaaaaaaaaabbaabbbaabbababbbbbaaaaaabaaabbbaabaaabbabbabaabbbbabbabb...

output:

2572
1235
1093
2907
2985
8864
4191
3837
1613
7566
4383
245
4022
8648
1690
367
2039
1028
3859
3340
183
2517
4485
1096
4366
1687
569
1481
1834
4970
7792
5304
136
2151
7030
2985
2874
4038
1468
1977
3064
1946
9349
74
7468
3189
5134
5616
184
1880
224
965
1610
917
604
1679
9087
7940
2
5226
406
2154
7268
6...

result:

wrong answer 1st numbers differ - expected: '605', found: '2572'

Test #11:

score: 0
Wrong Answer
time: 188ms
memory: 19928kb

input:

11 5
47391 45803
aababababbbbbbbbbbbaabaabababaababbbbabbabbabaabbbbabbbbaaaababbabababbabbabbaabbbaaabaaaabbbabababbaababbbabbabbabbbabaabbabaabaaaabbbbbbbbabbbbbababbaaababbbababbabaababbaaaaaaaaabaababaababbaaaabbbbaaababbaabaaabbabaaaaaabbababababbababaaaabbbaaaaaaaaaaabbbbbbbabbbaaabababaaababa...

output:

4953
4363
3381
6640
3030
14233
15728
705
1518
12279
5388
1962
5136
1726
1805
2856
253
1622
17661
4713
8486
9004
11694
2766
1128
14598
3906
12602
9679
7686
12484
5386
1416
81
11676
4304
8371
1853
8499
3312
14140
9611
4562
16700
3608
11308
1264
1935
3213
1717
9885
4976
3052
20890
1500
14191
5406
4763
...

result:

wrong answer 1st numbers differ - expected: '4187', found: '4953'

Test #12:

score: 0
Wrong Answer
time: 251ms
memory: 23396kb

input:

12 5
69918 68763
bbabbbabbbaaabaabbbbbbbbbabbbbbbbbaaabaabaabbbaabaaaabbabbabbbbbabbbbaabaaaabaabbababbbbbaaababbabbbbaabbbaaabaaaaababaaabbbbababababbababbbaaabbbbaabbabbbbbbbbabbabbbbaaabbbbaaababbbaaabaaabbabaaabbaabbbaaabbbbbbaabaabbbaabaaabbbabbbbbaabaabbabbbabbababbaaaabbbbbbbaabaaaabbabaaaaab...

output:

7399
24010
4742
6030
5870
2311
17859
8802
4827
10819
9686
22359
8931
2747
1247
1685
5625
25952
6901
13082
9061
33319
17573
3227
1061
362
25825
6307
13313
5098
2565
3456
5396
3862
22150
16458
11595
10983
7094
6850
10928
8554
5231
15240
22563
2428
2510
365
11173
25778
21343
2539
15166
2708
7587
6545
5...

result:

wrong answer 1st numbers differ - expected: '614', found: '7399'

Test #13:

score: 0
Wrong Answer
time: 306ms
memory: 25168kb

input:

13 5
86855 85346
bbaaababbbbbaaaabbbaabbabbabbaabbbabbbbbbbaabaabbaabbaaaabbabaaaabbaaaabababbbbbbbbaabbabababaabaababaaabbabaabaaabaabaabbbabbabbbaabaaaabbbbabbbaabbabaabbabbbaabbbbbaaaaabbbbaaaababbbabaaabaababaababaaabbbaaaababbabaababaabababaababbabbbabaabaaabbabababbbbbbaaaababababbabaabaaaaabb...

output:

29375
4491
42355
18976
16854
5471
39434
4497
10753
17708
34933
23458
13425
9895
28635
19086
18093
26540
8493
25687
5316
10929
3228
601
41902
6498
9715
26557
4139
33807
8129
25739
9863
7335
20222
15675
16518
1374
5187
2578
12810
8342
16496
8575
28450
1161
4465
10297
25194
22492
22810
20967
2797
33356...

result:

wrong answer 1st numbers differ - expected: '23397', found: '29375'

Test #14:

score: 0
Wrong Answer
time: 363ms
memory: 25852kb

input:

14 5
95651 97657
babbbababaaaabaaaaaaaabbaaabaababbaabbaabbabbaaabababaabaaaabaaaabbbabbabbaaaabbaabbbbbbbbaabbaabbbaaabaaabababbabababbabbbababaabaababbaabbababbbabbbbabbbbabbaaaaabaaaabbabbbabbbabbaababbbabbaaabaabbbbbbbabbabbbabaaaabaaaaaaaababaababbabaaaabaababaababbaaaaababaaabbbbabababbbabaabb...

output:

18359
34279
8116
10427
21300
11171
15292
688
13779
8128
34722
12425
30596
3881
9095
9759
42462
20358
15487
9206
21085
5487
8371
11638
209
20364
8670
39149
7181
39188
42676
1844
24925
4482
16526
11457
3812
7138
5504
6575
23576
10077
42082
46844
11334
11233
20234
20227
4179
36810
31640
15547
16200
414...

result:

wrong answer 1st numbers differ - expected: '16666', found: '18359'

Test #15:

score: 4
Accepted
time: 66ms
memory: 18448kb

input:

15 5
21209 21227
babababakakababfbrbabababauabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbalabababakabababfbababababakabababfbrbabababauabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabab...

output:

875
8428
694
990
9417
1004
607
3128
8428
528
10263
451
1510
1
8757
272
5285
2056
178
54
3412
1160
491
6677
6540
7486
707
409
919
377
3178
339
3932
28
338
421
39
992
1206
2689
712
20
437
5233
6165
9492
49
1315
3028
778
981
4525
4967
10255
1306
1015
1095
2415
1040
933
3517
1255
1117
8592
55
124
780
52...

result:

ok 110426 numbers

Test #16:

score: 4
Accepted
time: 297ms
memory: 23428kb

input:

16 5
73529 68306
babsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbabsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbrbsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbabsbababwbsbabsbabababsbabsbab...

output:

1
1262
2399
1
0
1
10730
1
0
1
30489
3312
4248
935
8645
14603
10699
0
0
13368
35363
10221
11654
32384
7456
15281
0
1
3274
17255
1
14138
8866
11994
34570
1
15001
8483
10232
4695
1473
635
16542
0
16332
4700
9621
2069
11473
0
3673
23257
4871
1
5197
13419
7209
1
14946
1
1
2201
9540
455
12114
15470
1
0
17...

result:

ok 359447 numbers

Test #17:

score: 4
Accepted
time: 308ms
memory: 25224kb

input:

17 5
87085 88577
ababababababvbabababababababababababvbabababababababababababvbabababatabababababababvbabababababababababababvbabababababababababababvbabababababababababababvbabababababababababababvbabababababababababababvbabababababababababababvbabababababababababababvbabababatabababababababvbababa...

output:

11254
27
760
3385
0
4335
871
683
513
2774
1250
1998
2174
2463
974
6871
13078
2817
2453
1096
3372
2677
0
513
36833
1611
6019
1681
43004
1353
12306
18622
39485
2589
37733
9624
589
1277
3638
526
1272
0
14907
40922
484
536
1394
35414
3661
37
0
1118
40967
2330
2103
1458
2071
3250
982
1862
190
1907
0
0
0
...

result:

ok 436679 numbers

Test #18:

score: 4
Accepted
time: 343ms
memory: 26040kb

input:

18 5
99489 97628
abababacababababacababababacababababacababababacababababacababababacababababacababababacababayabacababababacabababxbacababababacababababacababababacababababacababababacababababacababababacababababacababababacababayabacababababacababababacababababacababababacababababacababababacababa...

output:

445
707
42132
580
26762
655
39
497
44253
161
2051
39980
19110
40444
266
38617
11389
4931
29403
376
333
626
12248
653
10
648
686
24032
665
291
252
24777
44211
463
313
566
178
49505
25926
647
36
407
625
44175
46231
461
30278
25555
46539
15563
365
46328
554
624
524
27228
32996
577
33323
11690
459
36932...

result:

ok 475535 numbers

Test #19:

score: 0
Wrong Answer
time: 86ms
memory: 16692kb

input:

19 5
23197 23286
abbbaabaaabbaabbaaabaabbbabbabbhaabaaabbaabbaaabaabbbabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbaabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaahbbabbabbbaabaaabbaabbbaabaabbbabbabbbaabaaabbaabbaaabaabbbabbamb...

output:

2139
4934
2611
6954
7418
1313
3493
5258
3840
2898
931
3558
14
3970
3190
1210
9349
8737
4727
2302
5112
7273
3174
5166
118
1596
7385
203
779
7209
7340
3022
155
973
188
1155
8339
6480
5542
4492
513
5731
3382
7985
6475
760
4288
9340
3946
4242
4967
1603
489
5583
2486
2624
3477
2377
10997
3075
4937
11129
...

result:

wrong answer 1st numbers differ - expected: '1910', found: '2139'

Test #20:

score: 0
Wrong Answer
time: 184ms
memory: 19692kb

input:

20 5
49694 49669
bbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaa...

output:

14045
2546
5882
14100
6560
3895
45
9625
6915
3540
24100
12189
9405
14457
12080
19284
13122
2771
13781
1998
953
8474
22836
9927
5499
19647
5440
15549
492
2523
24537
10510
7558
217
10628
11889
5533
13015
2259
6221
16145
8010
4855
22622
11758
6840
533
4299
2669
34
5123
9334
8281
547
13653
7333
297
9054...

result:

wrong answer 1st numbers differ - expected: '13569', found: '14045'

Test #21:

score: 0
Wrong Answer
time: 279ms
memory: 23532kb

input:

21 5
74422 74421
baabbllbbaabblabbaabbllbbaabbllbblabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbblbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllpbaabbllbbaabbllbbaabpllbbaa...

output:

11732
13322
22694
23317
7984
16966
6177
26433
4480
10198
11988
5564
19004
5374
21512
9563
12373
2500
16766
14647
24586
19240
4924
2922
1012
23978
29373
7636
6251
68
25215
8837
21159
4680
6128
17717
28026
32591
24676
12404
20705
13748
29053
1955
20806
22949
2950
18940
706
8571
7821
35657
14393
7065
2...

result:

wrong answer 1st numbers differ - expected: '8464', found: '11732'

Test #22:

score: 0
Wrong Answer
time: 325ms
memory: 25472kb

input:

22 5
89983 89431
bajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbja...

output:

18401
4841
9716
11659
32100
14812
7649
10988
21526
27010
18027
552
20267
14298
25895
24588
2890
21255
3616
1863
2735
28169
34630
12454
10379
28469
26639
8917
4985
37509
5007
10957
3525
27219
6820
280
893
19655
26737
21064
488
139
24394
18744
10138
470
23446
29223
37268
8520
11942
19437
285
10307
196...

result:

wrong answer 1st numbers differ - expected: '11849', found: '18401'

Test #23:

score: 0
Wrong Answer
time: 343ms
memory: 26004kb

input:

23 5
94783 94700
baabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabavaabaabaaabbaabaaaabaabbaabbaapaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaaabaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaa...

output:

8472
9650
13663
34349
15759
19204
41596
13385
31249
10166
28727
3813
9536
6404
7148
5839
38049
22060
17223
4886
14620
10613
15987
374
2101
12198
3985
17086
16134
1618
15365
9806
12884
13
8056
10281
1483
4368
15848
5068
14684
1586
10137
929
4609
25477
2928
29093
38191
14870
33172
12175
4221
3259
1763...

result:

wrong answer 1st numbers differ - expected: '8010', found: '8472'

Test #24:

score: 0
Wrong Answer
time: 355ms
memory: 26172kb

input:

24 5
99576 99977
babbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbbabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbad...

output:

26864
35463
20121
29875
35847
9257
16230
5653
74
469
1216
7558
18389
4680
29982
5845
4382
43170
1739
3302
4961
21665
39558
1139
17549
7898
2274
19953
12225
26912
21991
19204
5042
41283
5860
21005
2265
5654
8430
17791
7779
1059
49441
4068
1214
19107
20785
24579
27086
11452
1510
21491
1237
16511
18548...

result:

wrong answer 1st numbers differ - expected: '25224', found: '26864'

Test #25:

score: 0
Wrong Answer
time: 383ms
memory: 26308kb

input:

25 5
99821 99309
aabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbbabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabeaabbaab...

output:

10138
16052
23438
14197
37740
19222
10112
11399
25087
34923
7916
20338
29843
11890
7336
24915
28297
13595
23464
7941
20628
43709
11089
13654
15591
37112
98
1314
5255
22485
18134
4781
15521
415
33666
4732
14754
24629
12371
6295
24634
2177
7699
17520
21345
14161
8913
5386
16666
41223
19552
2506
19959
...

result:

wrong answer 1st numbers differ - expected: '9293', found: '10138'