QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#258871#6759. 字符串w4p3r16 345ms75272kbC++204.9kb2023-11-20 12:40:552023-11-20 12:40:55

Judging History

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

  • [2023-11-20 12:40:55]
  • 评测
  • 测评结果:16
  • 用时:345ms
  • 内存:75272kb
  • [2023-11-20 12:40:55]
  • 提交

answer

#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define db double
#define ve vector<int>
#define pa pair<int,int>
#define fr first
#define sd second
#define pb push_back
#define mp make_pair
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
inline ll read()
{
	char ch = getchar();
	ll s = 0, w = 1;
	while (ch < '0' || ch > '9') {if (ch == '-')w = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {s = s * 10 + ch - '0'; ch = getchar();}
	return s * w;
}
int n, m;
string s;
#define N 400010
int X[N], R[N];
int ans[N];
namespace S1
{
int p[N], c[N];
vector<pair<int, int>>ad[N];
vector<pair<int, int>>qr[N];
void add(int x, int w) {for (; x <= n; x += x & (-x))c[x] += w;}
int qry(int x) {int s = 0; for (; x; x -= x & (-x))s += c[x]; return s;}
void sol()
{
	string ss = "0#";
	for (int i = 0; i < n; i ++)
	{
		ss += s[i] + '#';
	}
	ss += '1';
	int M = ss.length() - 2; int id = 0;
	for (int i = 1; i <= M; i ++)
	{
		if (p[id] + id > i)p[i] = min(p[id * 2 - i], p[id] + id - i);
		while (ss[i - p[i]] == ss[i + p[i]])p[i] ++;
		if (i + p[i] > id + p[id])id = i;
	}
	for (int i = 1; i <= M; i ++)if (ss[i] == '#')
		{
			int x = i / 2, len = p[i] / 2;
			int l0 = x - len + 1, r0 = x + len;
			// cout << "???:" << i << ' ' << l0 << ' ' << r0 << endl;
			assert(1 <= l0 && r0 <= n);
			if ((l0 == 1) || (r0 < n && s[r0 + 1] >= s[l0 - 1]))continue;
			ad[2 * x + 1].push_back({l0, x});
		}
	for (int i = 1; i <= m; i ++)qr[X[i] + R[i]].push_back({X[i], i});
	for (int i = 1; i <= 2 * n + 1; i ++)
	{
		for (auto [l, r] : ad[i]) {add(l, +1); add(r + 1, -1);}
		for (auto [x, id] : qr[i])ans[id] -= qry(x);
	}
	for (int i = 1; i <= 2 * n + 1; i ++)p[i] = 0, ad[i].clear(), qr[i].clear();
	for (int i = 1; i <= n; i ++)c[i] = 0;
}
}
namespace S2
{
int rk[N], x[N], y[N];
int c[N], sa[N];
int sum[2][N];
vector<int>ad[N];
vector<array<int, 3>>qr[N];
void add(int t, int x) {for (; x <= n; x += x & (-x))sum[t][x] ++;}
int qry(int t, int x) {int S = 0; for (; x; x -= x & (-x))S += sum[t][x]; return S;}
void SA(string ss)
{
	int m = 'z' + 1, n = ss.length() - 1;
	for (int i = 1; i <= n; i ++)c[x[i] = ss[i]] ++;
	for (int i = 1; i <= m; i ++)c[i] += c[i - 1];
	for (int i = 1; i <= n; i ++)sa[c[x[i]] --] = i;
	// for (int i = 1; i <= n; i ++)cout << sa[i] << ' '; cout << endl;
	for (int k = 1; k <= n; k <<= 1)
	{
		int num = 0;
		for (int i = n - k + 1; i <= n; i ++)y[++ num] = i;
		for (int i = 1; i <= n; i ++)if (sa[i] - k > 0)y[++ num] = sa[i] - k;
		for (int i = 1; i <= m; i ++)c[i] = 0;
		for (int i = 1; i <= n; i ++)c[x[i]] ++;
		for (int i = 1; i <= m; i ++)c[i] += c[i - 1];
		for (int i = n; i >= 1; i --)sa[c[x[y[i]]] --] = y[i], y[i] = 0;
		swap(x, y); x[sa[1]] = 1; num = 1;
		for (int i = 2; i <= n; i ++)x[sa[i]] = (y[sa[i]] == y[sa[i - 1]] && y[sa[i] + k] == y[sa[i - 1] + k] ? num : ++ num);
		if (num == n)break; m = num;
		// cout << "GG:" << k << endl;
		// for (int i = 1; i <= n; i ++)cout << sa[i] << ' '; cout << endl;
	}
	for (int i = 1; i <= max(n, 'z' + 1); i ++)x[i] = y[i] = c[i] = 0;
}
void sol()
{
	string t = s; reverse(t.begin(), t.end());
	string ss = "0" + s + char('z' + 1) + t;
	SA(ss);
	// cout << "??:" << ss << endl;;
	for (int i = 1; i <= 2 * n + 1; i ++)rk[sa[i]] = i;
	// for (int i = 1; i <= 2 * n + 1; i ++)cout << sa[i] << ' '; cout << endl;
	// for (int i = 1; i <= 2 * n + 1; i ++)cout << rk[i] << ' '; cout << endl;
	for (int i = n + 2; i <= 2 * n + 1; i ++)
	{
		ad[rk[i]].push_back(2 * n + 2 - i);
	}
	for (int i = 1; i <= m; i ++)
	{
		// cout << "GG:" << i << " " << X[i] << ' ' << rk[X[i]] << endl;
		qr[rk[X[i]]].push_back((array<int, 3>) {X[i], R[i], i});
	}
	for (int i = 2 * n + 1; i >= 1; i --)
	{
		for (int x : ad[i])add(x & 1, x);
		for (auto tmp : qr[i])
		{
			int x = tmp[0], r = tmp[1], id = tmp[2];
			// cout << "??:" << id << " " << x << ' ' << r << ' ' << qry((x & 1) ^ 1, x + 2 * r - 1) - qry((x & 1) ^ 1, x - 1) <<  endl;
			// cout << rk[x] << endl;
			// for (int i = x + 1; i <= x + 2 * r - 1; i += 2)cout << rk[2 * n + 2 - i] << ' '; cout << endl;
			ans[id] += qry((x & 1) ^ 1, x + 2 * r - 1) - qry((x & 1) ^ 1, x - 1);
		}
	}
	for (int i = 1; i <= 2 * n + 1; i ++)
	{
		sum[0][i] = sum[1][i] = 0; ad[i].clear(); qr[i].clear();
		sa[i] = rk[i] = 0;
	}
}
}
void sol()
{
	cin >> n >> m;
	cin >> s;
	for (int i = 1; i <= m; i ++)
	{
		cin >> X[i] >> R[i];
	}
	S1 :: sol();
	S2 :: sol();
	for (int i = 1; i <= m; i ++)cout << ans[i] << '\n';
	for (int i = 1; i <= m; i ++)ans[i] = 0;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int op, T;
	cin >> op >> T;
	while (T --)sol();
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 56100kb

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

result:

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

Test #2:

score: 0
Wrong Answer
time: 3ms
memory: 56504kb

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

result:

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

Test #3:

score: 0
Wrong Answer
time: 3ms
memory: 56724kb

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:

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

result:

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

Test #4:

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

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:

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

result:

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

Test #5:

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

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:

1
7
1
40
7
19
8
26
15
4
31
9
17
15
41
5
15
8
11
3
2
8
4
31
4
4
35
24
1
8
8
3
13
13
20
8
0
2
7
5
9
10
17
22
2
16
1
24
2
9
6
10
31
15
28
7
9
12
26
0
18
0
20
24
31
18
42
3
9
13
11
19
0
1
25
1
0
23
27
17
35
2
7
10
4
9
21
6
15
0
34
2
6
5
18
24
10
21
5
14
2
12
5
16
0
13
10
4
6
18
2
10
4
31
14
26
13
1
13
6...

result:

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

Test #6:

score: 0
Wrong Answer
time: 12ms
memory: 54516kb

input:

6 5
998 992
bibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbabbbaabpaapbaabbbabobabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbbbbaabpaapbaabbbbbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabobabbbaabpaapbaabbbabbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabf...

output:

34
51
43
62
267
135
145
111
337
313
88
337
142
174
174
97
79
19
156
291
125
24
112
18
13
171
61
127
8
76
216
59
1
201
45
50
128
9
3
120
135
218
0
32
106
62
5
356
142
41
53
60
89
39
53
210
260
20
13
194
356
78
65
54
299
60
139
311
199
122
118
118
209
8
9
68
264
310
368
2
356
7
15
33
120
57
8
93
68
36...

result:

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

Test #7:

score: 0
Wrong Answer
time: 21ms
memory: 56668kb

input:

7 5
1988 1997
bvappavbbaabavavpavbbaabbvappavbbaabbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbaabbvappavbbaabbvappavabaabbvappavbbaaqbvappavbbaabbpappavbqaabbvappavbbaabavappavbbaabbvappavbbapbbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbpabbvappavbba...

output:

20
303
419
405
6
12
676
787
520
153
146
130
634
4
160
795
146
106
329
395
45
39
132
151
222
2
8
301
49
314
92
196
38
57
6
124
558
828
512
89
13
140
222
47
492
96
124
111
64
12
437
35
1
169
681
135
205
306
114
454
97
228
421
114
664
85
45
104
714
28
42
9
17
182
616
82
19
715
92
446
261
171
14
503
58
...

result:

wrong answer 2nd numbers differ - expected: '302', found: '303'

Test #8:

score: 0
Wrong Answer
time: 11ms
memory: 56572kb

input:

8 5
2977 2978
aabaaaabaabaaaabaabaaaabaabnaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaanbaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaa...

output:

466
368
734
6
461
942
8
412
188
207
608
754
440
375
173
1044
567
1111
1112
1129
131
470
957
1334
30
1029
887
56
690
1167
102
802
128
842
54
372
104
9
936
124
1150
758
239
790
607
23
378
346
52
1324
662
435
14
358
508
731
1268
503
206
154
493
740
256
128
671
106
1203
239
1281
891
903
214
418
315
399
...

result:

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

Test #9:

score: 0
Wrong Answer
time: 21ms
memory: 58720kb

input:

9 5
3992 3963
baaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambbabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbabbmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabma...

output:

338
177
336
702
22
1030
512
926
1489
1780
102
448
1243
1608
544
21
314
269
325
477
88
1128
20
372
311
1048
464
80
1178
973
203
6
626
846
652
721
477
87
361
700
829
501
1744
121
326
435
41
892
203
208
64
135
1255
53
814
495
870
847
793
61
1433
1546
5
29
52
19
430
842
1244
754
1304
226
179
110
1156
32...

result:

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

Test #10:

score: 0
Wrong Answer
time: 48ms
memory: 60632kb

input:

10 5
21773 22026
babaaababbabbbbbaababbababaabbababbabbbbabaaaaabaabbabbbbbbaaaabaababbbabbbbbabaababbaababbbbaaabaabbaaaabbbbaaaabbbbbabaaaaaaaabbabbabbaabbbbabbbaaabbabbabababbaabaabbaabbaaaaabaabaababaabbaaaaaabababbaabbababaabbabbaaaaaaaaabbaabbbaabbababbbbbaaaaaabaaabbbaabaaabbabbabaabbbbabbabb...

output:

606
606
872
1877
2960
7800
3875
2952
39
6360
3249
67
2082
6988
394
191
1152
893
2734
2346
25
1130
3784
44
2336
1221
547
1245
169
4481
7213
4746
127
1065
6830
1658
2057
3586
1335
1398
1853
1172
6995
38
5093
2550
3490
3992
161
604
45
936
1272
335
251
1312
7945
6837
0
3573
333
1694
6539
5741
1894
8431
...

result:

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

Test #11:

score: 0
Wrong Answer
time: 103ms
memory: 65736kb

input:

11 5
47391 45803
aababababbbbbbbbbbbaabaabababaababbbbabbabbabaabbbbabbbbaaaababbabababbabbabbaabbbaaabaaaabbbabababbaababbbabbabbabbbabaabbabaabaaaabbbbbbbbabbbbbababbaaababbbababbabaababbaaaaaaaaabaababaababbaaaabbbbaaababbaabaaabbabaaaaaabbababababbababaaaabbbaaaaaaaaaaabbbbbbbabbbaaabababaaababa...

output:

4187
3689
103
3723
2769
13828
13979
644
1459
10311
4490
1556
3876
1467
349
637
253
32
13745
3311
4567
8057
8349
1535
688
13113
484
8598
8775
4255
9925
3225
1010
80
8866
3892
7422
1583
7337
3033
10456
7159
3244
16103
3328
8457
366
1124
2164
1566
7741
4081
2562
18855
1239
10075
1016
2604
1382
4438
663...

result:

wrong answer 2nd numbers differ - expected: '3688', found: '3689'

Test #12:

score: 0
Wrong Answer
time: 194ms
memory: 70620kb

input:

12 5
69918 68763
bbabbbabbbaaabaabbbbbbbbbabbbbbbbbaaabaabaabbbaabaaaabbabbabbbbbabbbbaabaaaabaabbababbbbbaaababbabbbbaabbbaaabaaaaababaaabbbbababababbababbbaaabbbbaabbabbbbbbbbabbabbbbaaabbbbaaababbbaaabaaabbabaaabbaabbbaaabbbbbbaabaabbbaabaaabbbabbbbbaabaabbabbbabbababbaaaabbbbbbbaabaaaabbabaaaaab...

output:

615
22361
3580
4071
4362
2218
17422
6215
4184
8819
7590
19792
8267
1773
46
1287
3821
25097
6604
10307
7693
26755
13718
3090
149
340
23284
4036
10048
3452
2001
687
4222
3170
17770
13156
8110
10690
4354
3601
9031
8540
3752
15175
18010
2243
1614
221
6139
22729
21068
1844
14875
1760
5014
2672
4514
13169...

result:

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

Test #13:

score: 0
Wrong Answer
time: 223ms
memory: 71584kb

input:

13 5
86855 85346
bbaaababbbbbaaaabbbaabbabbabbaabbbabbbbbbbaabaabbaabbaaaabbabaaaabbaaaabababbbbbbbbaabbabababaabaababaaabbabaabaaabaabaabbbabbabbbaabaaaabbbbabbbaabbabaabbabbbaabbbbbaaaaabbbbaaaababbbabaaabaababaababaaabbbaaaababbabaababaabababaababbabbbabaabaaabbabababbbbbbaaaababababbabaabaaaaabb...

output:

23397
497
37521
13084
16191
5015
39199
2818
7676
13149
29388
16788
9755
6909
28102
17426
12692
25730
7138
20353
5087
8739
2658
496
34203
3816
7691
18151
208
26131
7994
21088
3198
3551
17965
13389
12003
1099
4938
2051
9546
461
8972
3718
24215
1107
1632
6965
22150
16897
21693
16811
2538
32409
12849
11...

result:

wrong answer 5th numbers differ - expected: '16190', found: '16191'

Test #14:

score: 0
Wrong Answer
time: 268ms
memory: 75272kb

input:

14 5
95651 97657
babbbababaaaabaaaaaaaabbaaabaababbaabbaabbabbaaabababaabaaaabaaaabbbabbabbaaaabbaabbbbbbbbaabbaabbbaaabaaabababbabababbabbbababaabaababbaabbababbbabbbbabbbbabbaaaaabaaaabbabbbabbbabbaababbbabbaaabaabbbbbbbabbabbbabaaaabaaaaaaaababaababbabaaaabaababaababbaaaaababaaabbbbabababbbabaabb...

output:

16666
26260
7301
9220
17849
7041
13588
538
10511
5250
30399
9348
28342
3847
7513
9692
41790
18592
13195
7424
18368
4494
735
9224
201
13124
6893
31857
5055
34072
32148
1798
17635
3488
15848
8096
2947
5926
5118
5356
12682
10065
37287
36556
10885
2817
19447
15735
2005
27803
26892
12199
14432
36471
9213...

result:

wrong answer 4th numbers differ - expected: '9219', found: '9220'

Test #15:

score: 4
Accepted
time: 64ms
memory: 60636kb

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: 209ms
memory: 69960kb

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: 281ms
memory: 74088kb

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: 308ms
memory: 73916kb

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: 73ms
memory: 58716kb

input:

19 5
23197 23286
abbbaabaaabbaabbaaabaabbbabbabbhaabaaabbaabbaaabaabbbabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbaabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaahbbabbabbbaabaaabbaabbbaabaabbbabbabbbaabaaabbaabbaaabaabbbabbamb...

output:

1910
2683
1805
4506
5628
1092
2564
4921
2074
2060
437
2768
12
3750
3033
1102
8738
7615
2668
792
3839
5640
3109
4979
97
883
4765
42
673
7203
4568
2555
134
824
165
430
5246
6150
3669
4357
278
5175
2960
5078
5646
372
3912
6780
1678
2852
2623
1167
270
4198
2353
2213
1827
483
8848
2891
4029
10344
6669
18...

result:

wrong answer 2nd numbers differ - expected: '2681', found: '2683'

Test #20:

score: 0
Wrong Answer
time: 139ms
memory: 65600kb

input:

20 5
49694 49669
bbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaa...

output:

13572
1022
5376
9536
1705
1799
33
1979
2448
2437
20681
5766
7265
1053
11906
19152
10709
2558
2229
1561
635
5204
22617
9942
5392
16733
4149
14323
448
1313
20353
5064
6234
221
8660
3363
4789
4215
2203
4612
15393
5473
4259
21903
10085
6415
297
2160
2480
38
768
6944
3403
374
11748
6217
141
1035
2384
26
...

result:

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

Test #21:

score: 0
Wrong Answer
time: 239ms
memory: 69292kb

input:

21 5
74422 74421
baabbllbbaabblabbaabbllbbaabbllbblabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbblbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllpbaabbllbbaabbllbbaabpllbbaa...

output:

8464
12810
14893
15418
2088
15622
4854
25183
3568
9950
10864
455
8991
3496
13293
6664
9956
1389
10607
9952
20962
10721
285
345
684
19342
23365
3210
6242
30
23136
3419
17635
4455
5781
15887
25370
32446
23800
8010
17237
10472
24074
1551
17220
20157
954
15969
325
4415
7360
29545
13604
3148
19995
4775
9...

result:

wrong answer 2nd numbers differ - expected: '12807', found: '12810'

Test #22:

score: 0
Wrong Answer
time: 299ms
memory: 74008kb

input:

22 5
89983 89431
bajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbja...

output:

11850
4470
9680
10841
25353
5872
5146
8020
8837
7876
14485
396
6546
4575
23186
18650
2244
20336
736
1465
520
21158
32926
12087
10329
27915
26183
7147
2530
34776
4770
9998
1168
17022
5020
248
573
19548
26220
15096
445
109
12051
15361
8025
285
19816
25567
31750
8006
11751
12204
183
9930
19054
14278
30...

result:

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

Test #23:

score: 0
Wrong Answer
time: 323ms
memory: 73872kb

input:

23 5
94783 94700
baabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabavaabaabaaabbaabaaaabaabbaabbaapaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaaabaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaa...

output:

8045
2026
11771
26959
10327
14092
36040
9210
29683
9971
26258
3343
1339
4312
3852
1007
29532
20421
13041
2528
14574
8892
15588
219
807
8789
3064
10329
15478
1155
7873
9745
11345
13
1845
8621
290
3119
14916
2032
8297
1551
6960
544
2856
16593
2052
26688
37561
3144
31237
5568
3355
2908
1760
7871
5871
2...

result:

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

Test #24:

score: 0
Wrong Answer
time: 345ms
memory: 74196kb

input:

24 5
99576 99977
babbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbbabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbad...

output:

25234
22884
4206
25969
30497
8687
15592
4265
24
3
680
3537
18273
725
29249
5674
2310
34071
1098
2151
1226
17815
26165
310
13480
7902
951
13545
7389
17395
16710
13917
4721
35023
5767
16848
1661
3850
5424
13560
7245
925
39107
2838
1106
13497
20013
19227
16488
4070
1265
16436
553
13228
11879
16012
1914...

result:

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

Test #25:

score: 0
Wrong Answer
time: 336ms
memory: 74644kb

input:

25 5
99821 99309
aabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbbabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabeaabbaab...

output:

9305
10238
15505
4886
29725
9466
6165
10276
13792
30290
4377
12591
23524
10311
1237
14624
18817
3750
8903
7662
2500
27158
3517
12933
14134
24136
21
969
4128
15324
1065
3218
5259
322
32594
190
5353
15125
7339
5502
20828
1606
7651
17296
9822
9704
265
2996
503
33951
5003
2405
13469
1898
815
7458
27100
...

result:

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