QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#258863#6759. 字符串w4p3r4 339ms72692kbC++204.8kb2023-11-20 12:23:572023-11-20 12:23:57

Judging History

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

  • [2023-11-20 12:23:57]
  • 评测
  • 测评结果:4
  • 用时:339ms
  • 内存:72692kb
  • [2023-11-20 12:23:57]
  • 提交

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;
			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 = 1; i <= n; 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);
	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[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: 5ms
memory: 58140kb

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:

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

result:

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

Test #2:

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

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:

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

result:

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

Test #3:

score: 0
Wrong Answer
time: 10ms
memory: 56152kb

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
0
3
0
5
1
0
3
5
5
5
7
3
6
3
0
0
0
0
0
3
1
4
4
0
1
3
0
1
0
4
2
3
0
0
1
0
0
6
1
1
1
5
1
1
2
4
3
4
1
4
2
7
1
7
7
3
5
0
6
2
2
0
0
0
0
0
7
3
0
9
2
4
0
0
0
7
1
5
5
9
5
5
1
4
0
3
1
1
8
0
8
4
0
0
2

result:

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

Test #4:

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

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
6
5
17
15
17
4
19
1
1
2
4
6
5
4
7
3
6
4
0
4
9
7
0
7
17
3
3
19
16
4
2
2
15
1
9
19
1
3
9
3
17
0
17
0
4
0
7
10
7
7
7
12
6
0
19
0
6
6
1
6
15
7
1
15
1
0
6
21
8
7
8
1
0
0
20
2
7
7
3
2
6
6
9
3
1
13
1
13
8
6
18
0
1
1
14
0
3
0
11
2
10
12
3
0
0
21
2
3
22
21
15
3
7
3
11
1
0
8
0
1
19
15
5
4
4
0
1
9
2
12
1
...

result:

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

Test #5:

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

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:

7
6
1
24
6
7
1
2
0
4
16
14
8
20
24
11
20
3
15
0
9
0
7
44
3
15
19
42
1
22
12
5
16
0
26
12
5
1
3
0
5
13
10
13
2
21
3
31
6
16
9
0
29
13
15
3
0
1
2
1
9
1
2
32
44
11
25
4
10
5
15
37
2
2
22
2
5
2
38
13
28
0
8
5
2
11
39
8
13
1
17
2
8
7
23
44
5
2
3
5
1
4
2
18
0
8
14
10
10
23
13
4
3
37
5
43
19
2
5
10
6
8
12
...

result:

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

Test #6:

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

input:

6 5
998 992
bibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbabbbaabpaapbaabbbabobabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbbbbaabpaapbaabbbbbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabobabbbaabpaapbaabbbabbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabf...

output:

134
40
156
70
234
45
128
177
285
302
32
287
109
30
106
145
173
129
133
408
100
118
234
5
71
73
136
160
7
73
305
51
1
172
26
106
99
38
2
67
110
138
3
17
36
88
5
285
48
95
48
234
81
11
18
135
219
41
17
114
327
86
241
18
263
21
181
258
43
101
203
100
132
24
10
61
384
250
306
9
289
8
2
12
21
9
9
124
54
...

result:

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

Test #7:

score: 0
Wrong Answer
time: 16ms
memory: 58480kb

input:

7 5
1988 1997
bvappavbbaabavavpavbbaabbvappavbbaabbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbaabbvappavbbaabbvappavabaabbvappavbbaaqbvappavbbaabbpappavbqaabbvappavbbaabavappavbbaabbvappavbbapbbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbpabbvappavbba...

output:

102
182
346
454
98
89
534
636
347
106
188
171
499
0
213
617
86
80
293
322
49
19
105
0
257
17
91
301
65
269
70
146
18
55
112
160
759
934
763
97
22
211
245
68
393
6
86
157
46
63
304
5
6
289
543
142
274
389
114
268
103
159
515
122
442
80
45
100
612
32
30
6
10
175
675
118
11
915
79
393
253
153
24
560
91...

result:

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

Test #8:

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

input:

8 5
2977 2978
aabaaaabaabaaaabaabaaaabaabnaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaanbaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaa...

output:

299
343
1045
3
1048
500
339
1458
137
611
1067
790
817
1081
88
360
192
383
406
427
64
836
810
499
17
679
324
119
1210
450
241
298
64
293
120
1098
54
31
339
320
438
282
134
385
1107
8
216
178
180
503
640
367
25
471
1010
648
474
891
216
78
629
391
591
365
1177
185
513
601
478
326
770
107
805
159
1030
3...

result:

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

Test #9:

score: 0
Wrong Answer
time: 14ms
memory: 58792kb

input:

9 5
3992 3963
baaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambbabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbabbmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabma...

output:

211
286
293
554
11
1024
471
1314
1200
1016
53
374
978
1281
556
26
385
246
567
376
69
875
23
468
320
544
368
112
952
1395
119
10
326
440
847
640
844
96
476
988
1446
438
996
147
614
649
25
1419
200
364
71
138
740
52
719
880
393
410
1259
81
807
906
4
37
64
23
264
932
756
1376
725
208
240
124
708
183
63...

result:

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

Test #10:

score: 0
Wrong Answer
time: 46ms
memory: 61428kb

input:

10 5
21773 22026
babaaababbabbbbbaababbababaabbababbabbbbabaaaaabaabbabbbbbbaaaabaababbbabbbbbabaababbaababbbbaaabaabbaaaabbbbaaaabbbbbabaaaaaaaabbabbabbaabbbbabbbaaabbabbabababbaabaabbaabbaaaaabaabaababaabbaaaaaabababbaabbababaabbabbaaaaaaaaabbaabbbaabbababbbbbaaaaaabaaabbbaabaaabbabbabaabbbbabbabb...

output:

4099
409
1574
1358
526
4755
4783
4995
2604
8045
5284
445
1371
5655
2692
383
717
1546
1545
3937
341
4605
3055
1768
1500
1991
81
2108
3096
1030
8832
1150
76
4075
7789
1068
1215
4075
314
754
876
613
6214
25
9091
380
2578
7059
136
3707
366
138
154
1626
1032
1070
4807
8580
3
6438
601
2990
7480
4653
3345
...

result:

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

Test #11:

score: 0
Wrong Answer
time: 95ms
memory: 63008kb

input:

11 5
47391 45803
aababababbbbbbbbbbbaabaabababaababbbbabbabbabaabbbbabbbbaaaababbabababbabbabbaabbbaaabaaaabbbabababbaababbbabbabbabbbabaabbabaabaaaabbbbbbbbabbbbbababbaaababbbababbabaababbaaaaaaaaabaababaababbaaaabbbbaaababbaabaaabbabaaaaaabbababababbababaaaabbbaaaaaaaaaaabbbbbbbabbbaaabababaaababa...

output:

5298
157
5541
2399
3140
8060
8648
718
2128
8488
6862
172
3445
1800
2860
4657
50
2650
23231
5716
2965
2006
14584
748
327
8096
6732
15352
10076
2833
8088
6716
1678
106
7766
4505
8531
2371
449
3777
16962
6442
4987
10291
4033
13764
2413
502
4044
828
6234
22
4427
11604
1103
17699
8521
1649
1207
151
786
4...

result:

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

Test #12:

score: 0
Wrong Answer
time: 177ms
memory: 68652kb

input:

12 5
69918 68763
bbabbbabbbaaabaabbbbbbbbbabbbbbbbbaaabaabaabbbaabaaaabbabbabbbbbabbbbaabaaaabaabbababbbbbaaababbabbbbaabbbaaabaaaaababaaabbbbababababbababbbaaabbbbaabbabbbbbbbbabbabbbbaaabbbbaaababbbaaabaaabbabaaabbaabbbaaabbbbbbaabaabbbaabaaabbbabbbbbaabaabbabbbabbababbaaaabbbbbbbaabaaaabbabaaaaab...

output:

12569
27495
6122
6328
6379
2595
10146
3326
5081
6910
12690
11936
10042
1190
1891
133
6911
28194
9184
8292
428
21568
1480
506
1597
47
14208
2805
17233
5210
211
5412
3414
5720
27663
20589
14301
1816
2240
2454
67
11541
2024
9040
28145
609
739
449
4106
25653
23679
1120
8712
2766
8023
11694
7712
10572
67...

result:

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

Test #13:

score: 0
Wrong Answer
time: 202ms
memory: 68624kb

input:

13 5
86855 85346
bbaaababbbbbaaaabbbaabbabbabbaabbbabbbbbbbaabaabbaabbaaaabbabaaaabbaaaabababbbbbbbbaabbabababaabaababaaabbabaabaaabaabaabbbabbabbbaabaaaabbbbabbbaabbabaabbabbbaabbbbbaaaaabbbbaaaababbbabaaabaababaababaaabbbaaaababbabaababaabababaababbabbbabaabaaabbabababbbbbbaaaababababbabaabaaaaabb...

output:

36956
7787
22958
7313
2591
2804
23383
1344
11303
21307
25986
27446
5506
10671
31829
4312
22671
16428
201
34059
7080
1337
23
54
30428
1737
13812
32566
6854
22781
9065
32710
19278
13610
3829
16635
6859
1933
3171
3655
15405
13809
5780
15299
19634
1586
8923
5007
25375
14997
13779
13589
2912
18962
8989
1...

result:

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

Test #14:

score: 0
Wrong Answer
time: 242ms
memory: 69532kb

input:

14 5
95651 97657
babbbababaaaabaaaaaaaabbaaabaababbaabbaabbabbaaabababaabaaaabaaaabbbabbabbaaaabbaabbbbbbbbaabbaabbbaaabaaabababbabababbabbbababaabaababbaabbababbbabbbbabbbbabbaaaaabaaaabbabbbabbbabbaababbbabbaaabaabbbbbbbabbabbbabaaaabaaaaaaaababaababbabaaaabaababaababbaaaaababaaabbbbabababbbabaabb...

output:

4233
44350
8234
5647
15712
11343
15598
50
9195
8351
34790
8332
16117
712
263
10968
24280
4620
672
1052
15176
3933
14088
14676
115
9479
5600
25303
7830
27732
28227
2092
31119
496
18002
12253
309
9096
1333
9153
8296
13545
23056
31945
14963
21336
3044
13856
7729
24353
22031
20647
8877
21919
4308
14667
...

result:

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

Test #15:

score: 0
Wrong Answer
time: 54ms
memory: 59764kb

input:

15 5
21209 21227
babababakakababfbrbabababauabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbalabababakabababfbababababakabababfbrbabababauabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabababfbababababakabab...

output:

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

result:

wrong answer 12th numbers differ - expected: '451', found: '452'

Test #16:

score: 0
Wrong Answer
time: 216ms
memory: 65400kb

input:

16 5
73529 68306
babsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbabsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbrbsbababwbsbabsbabababsbabsbababwbsbadsbababwbsbabsbabsbwbsbabsbababwbsbabsbababwbsbabsbababwbsbabsbabababsbabsbab...

output:

1
1262
2399
0
0
1
10730
1
0
1
30489
3312
4248
935
8645
14603
10699
0
0
13368
35363
10221
11654
32384
7456
15281
0
0
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
0
14946
1
1
2201
9540
455
12114
15470
0
0
17...

result:

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

Test #17:

score: 0
Wrong Answer
time: 264ms
memory: 68216kb

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
3357
2677
0
513
36833
1611
6019
1681
43004
1353
12306
18622
39485
2589
37733
9624
589
1277
3638
526
1272
0
14907
40922
482
536
1394
35414
3661
37
0
1118
40967
2330
2103
1458
2071
3250
982
1862
190
1907
0
0
39...

result:

wrong answer 21st numbers differ - expected: '3372', found: '3357'

Test #18:

score: 4
Accepted
time: 309ms
memory: 69896kb

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: 64ms
memory: 61188kb

input:

19 5
23197 23286
abbbaabaaabbaabbaaabaabbbabbabbhaabaaabbaabbaaabaabbbabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbaabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaahbbabbabbbaabaaabbaabbbaabaabbbabbabbbaabaaabbaabbaaabaabbbabbamb...

output:

3081
1528
1955
5313
6916
779
632
540
3476
3277
192
3320
18
3305
4556
796
5217
5578
1362
1405
5085
6718
2557
3919
181
476
6307
247
1161
5701
6614
1882
431
254
151
729
7532
5014
1876
3489
1617
7791
2155
7109
4132
197
2440
5803
1919
4711
1342
4189
425
5552
432
1630
906
2864
7193
1730
389
5571
3629
3626...

result:

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

Test #20:

score: 0
Wrong Answer
time: 138ms
memory: 65392kb

input:

20 5
49694 49669
bbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaa...

output:

2914
2104
1451
7371
5425
2653
24
8164
4998
1790
18961
8218
11273
13954
2597
22797
13541
637
12326
227
1218
11289
20066
2252
6581
18350
6484
4244
409
1520
23376
8155
7171
4892
653
9524
4375
9276
549
1761
2797
10059
5113
19051
11026
1110
11630
3310
2183
9
2819
9139
6879
11905
1999
704
43
4769
4408
210...

result:

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

Test #21:

score: 0
Wrong Answer
time: 241ms
memory: 69060kb

input:

21 5
74422 74421
baabbllbbaabblabbaabbllbbaabbllbblabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbblbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllpbaabbllbbaabbllbbaabpllbbaa...

output:

4554
4983
22039
22865
2468
15530
7582
24992
2034
15440
13294
5523
15102
6130
15375
12657
5901
1543
23055
9663
11950
16771
78
458
708
11177
23201
3467
88
53
22820
8346
17589
1815
3651
15699
25126
32320
15418
11779
19095
7948
24006
2403
17160
10573
2189
9833
558
4771
6386
29463
13394
6294
19770
5020
1...

result:

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

Test #22:

score: 0
Wrong Answer
time: 286ms
memory: 69184kb

input:

22 5
89983 89431
bajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbja...

output:

9182
12145
4532
9735
25321
12567
3918
7905
15944
24094
9984
305
19680
13843
24343
17216
2058
18813
143
3301
84
13157
25766
17023
10598
29498
18178
4954
3922
28360
6521
4604
2605
7062
4887
167
842
9156
35047
11726
202
69
18860
9072
8066
82
12313
24395
29087
21341
12314
5029
73
13344
13778
15095
28631...

result:

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

Test #23:

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

input:

23 5
94783 94700
baabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabavaabaabaaabbaabaaaabaabbaabbaapaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaaabaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaa...

output:

2976
7122
5081
22241
20799
9815
18650
2319
13560
3991
13431
7456
7808
799
8999
5003
21619
10759
9934
2108
42117
2993
4994
461
2929
21371
2236
9172
6929
133
12843
3948
3058
13
5686
2897
1290
2323
5167
9102
406
558
940
1142
1933
14023
4408
13850
14890
10922
11663
681
4147
6163
2067
2491
1805
27247
958...

result:

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

Test #24:

score: 0
Wrong Answer
time: 339ms
memory: 70800kb

input:

24 5
99576 99977
babbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbbabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbad...

output:

20679
22819
19975
13638
30606
21103
2474
24544
18
23
5047
4480
13438
4914
42538
3329
18014
39786
1081
7852
4428
16203
26103
282
13461
18525
749
7390
5931
6463
21675
18242
3856
35285
3921
17277
633
14337
2014
17616
5996
4707
40218
17404
974
19044
29793
17620
3735
2736
624
20787
602
11937
11876
2196
1...

result:

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

Test #25:

score: 0
Wrong Answer
time: 331ms
memory: 72692kb

input:

25 5
99821 99309
aabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbbabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabeaabbaab...

output:

7163
11555
8203
12030
32138
15096
9360
7997
17597
23930
7704
6920
25122
5580
7071
6929
25918
12229
4445
6115
1848
24706
9549
7738
12381
21603
84
14879
3329
15260
17841
4367
12973
370
25788
4795
12222
17051
11812
4404
20606
1352
3754
8473
16805
9578
8952
5324
16743
27366
3149
1964
13761
1507
25662
12...

result:

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