QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#258882#6759. 字符串w4p3r16 383ms78308kbC++205.0kb2023-11-20 12:53:042023-11-20 12:53:05

Judging History

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

  • [2023-11-20 12:53:05]
  • 评测
  • 测评结果:16
  • 用时:383ms
  • 内存:78308kb
  • [2023-11-20 12:53:04]
  • 提交

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 += '#';
	}
	ss += '1';
	// cout << "EMM:" << ss << endl;
	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;
	}
	// cout << ss << endl;
	// for (int i = 1; i <= M; i ++)cout << p[i] << ' '; cout << endl;
	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;
			// cout << "???:" << x << ' ' << l0 << ' ' << r0 << " " << len << endl;
			ad[2 * x + 1].push_back({l0, x});
		}
	for (int i = 1; i <= m; i ++)qr[2 * X[i] + 2 * R[i] - 1].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: 7ms
memory: 54080kb

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: 12ms
memory: 56128kb

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

result:

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

Test #3:

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

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

result:

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

Test #4:

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

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

result:

wrong answer 10th numbers differ - expected: '0', found: '2'

Test #5:

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

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:

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

result:

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

Test #6:

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

input:

6 5
998 992
bibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbabbbaabpaapbaabbbabobabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbbbbaabpaapbaabbbbbbbabbaabbaafbaabbaabbaabbaabfaabbaabbabobabbbaabpaapbaabbbabbbabbaabbaafbaabbaabbaabbaabfaabbaabbabbbbibbaabpaapbaabbibbbbabbaabbaafbaabbaabbaabbaabf...

output:

34
51
43
61
267
135
144
111
336
313
88
335
142
174
174
97
77
19
156
291
123
22
112
18
13
168
60
127
6
75
216
59
1
200
45
50
127
8
3
120
134
218
0
31
106
61
5
356
142
41
53
59
88
39
53
210
260
20
12
192
356
77
65
54
297
60
139
309
199
122
118
115
209
8
9
67
264
308
368
2
355
6
15
33
120
56
8
93
67
36...

result:

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

Test #7:

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

input:

7 5
1988 1997
bvappavbbaabavavpavbbaabbvappavbbaabbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbaabbvappavbbaabbvappavabaabbvappavbbaaqbvappavbbaabbpappavbqaabbvappavbbaabavappavbbaabbvappavbbapbbvappavbbaabbvappavbbaaqbvappavbbaabbvappavbqaabbvappavbbaabbvappavbbpabbvappavbba...

output:

20
303
418
405
5
12
676
787
520
152
143
126
634
4
159
795
146
105
328
394
44
38
131
151
218
1
8
301
48
313
90
196
37
53
5
123
557
828
512
87
13
140
221
46
492
96
124
110
64
11
436
35
0
168
681
134
203
304
114
454
96
226
421
114
663
85
45
104
713
28
42
8
16
180
613
80
15
713
90
446
260
171
14
502
57
...

result:

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

Test #8:

score: 0
Wrong Answer
time: 19ms
memory: 54748kb

input:

8 5
2977 2978
aabaaaabaabaaaabaabaaaabaabnaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaanbaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaaabaabaaa...

output:

464
308
734
0
426
923
7
412
130
207
526
722
381
375
124
1044
567
1111
1070
1041
69
391
878
1255
30
1028
849
35
608
1089
72
740
106
833
54
372
16
9
902
124
1067
688
233
760
539
17
378
261
52
1246
662
424
-5
358
456
669
1189
428
150
134
485
722
228
116
584
53
1150
239
1204
847
829
138
366
235
399
1139...

result:

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

Test #9:

score: 0
Wrong Answer
time: 30ms
memory: 57008kb

input:

9 5
3992 3963
baaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambbabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbabbmarbaaaabrambaabbaabmarbaaaabrambaabbaabmarbaaaabrambaabbaaamarbaaaabramaaabbaabmarbaaaabrambaabbaabma...

output:

338
177
335
700
21
1029
510
926
1488
1778
101
448
1240
1608
544
20
314
268
324
474
87
1127
20
372
311
1048
463
80
1177
972
203
6
626
846
652
718
477
87
361
699
829
499
1742
120
324
433
41
892
203
206
64
134
1254
53
812
493
867
846
793
61
1433
1545
5
27
51
19
429
842
1243
752
1303
225
177
108
1155
32...

result:

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

Test #10:

score: 0
Wrong Answer
time: 60ms
memory: 62756kb

input:

10 5
21773 22026
babaaababbabbbbbaababbababaabbababbabbbbabaaaaabaabbabbbbbbaaaabaababbbabbbbbabaababbaababbbbaaabaabbaaaabbbbaaaabbbbbabaaaaaaaabbabbabbaabbbbabbbaaabbabbabababbaabaabbaabbaaaaabaabaababaabbaaaaaabababbaabbababaabbabbaaaaaaaaabbaabbbaabbababbbbbaaaaaabaaabbbaabaaabbabbabaabbbbabbabb...

output:

606
606
871
1877
2959
7800
3875
2952
38
6360
3249
66
2081
6988
394
191
1152
892
2733
2346
24
1129
3784
43
2336
1221
546
1245
169
4481
7213
4746
127
1064
6830
1658
2057
3586
1335
1398
1853
1172
6995
38
5093
2549
3490
3992
161
604
45
935
1272
333
250
1312
7944
6837
-1
3573
332
1693
6539
5741
1894
8430...

result:

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

Test #11:

score: 0
Wrong Answer
time: 127ms
memory: 66056kb

input:

11 5
47391 45803
aababababbbbbbbbbbbaabaabababaababbbbabbabbabaabbbbabbbbaaaababbabababbabbabbaabbbaaabaaaabbbabababbaababbbabbabbabbbabaabbabaabaaaabbbbbbbbabbbbbababbaaababbbababbabaababbaaaaaaaaabaababaababbaaaabbbbaaababbaabaaabbabaaaaaabbababababbababaaaabbbaaaaaaaaaaabbbbbbbabbbaaabababaaababa...

output:

4187
3688
102
3723
2769
13827
13979
644
1459
10311
4490
1556
3876
1467
349
635
253
31
13745
3311
4567
8057
8349
1533
688
13113
484
8598
8775
4255
9924
3225
1010
80
8866
3892
7422
1583
7336
3033
10456
7159
3244
16103
3328
8457
365
1123
2163
1566
7741
4081
2562
18854
1239
10075
1015
2604
1382
4438
663...

result:

wrong answer 3rd numbers differ - expected: '103', found: '102'

Test #12:

score: 0
Wrong Answer
time: 203ms
memory: 71152kb

input:

12 5
69918 68763
bbabbbabbbaaabaabbbbbbbbbabbbbbbbbaaabaabaabbbaabaaaabbabbabbbbbabbbbaabaaaabaabbababbbbbaaababbabbbbaabbbaaabaaaaababaaabbbbababababbababbbaaabbbbaabbabbbbbbbbabbabbbbaaabbbbaaababbbaaabaaabbabaaabbaabbbaaabbbbbbaabaabbbaabaaabbbabbbbbaabaabbabbbabbababbaaaabbbbbbbaabaaaabbabaaaaab...

output:

615
22361
3580
4071
4362
2218
17422
6215
4184
8818
7590
19791
8267
1773
45
1286
3820
25097
6604
10306
7693
26755
13718
3090
148
340
23284
4036
10048
3452
2000
685
4222
3169
17770
13156
8110
10690
4354
3601
9031
8539
3752
15175
18009
2243
1614
221
6139
22729
21068
1844
14875
1760
5014
2671
4514
13168...

result:

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

Test #13:

score: 0
Wrong Answer
time: 284ms
memory: 73532kb

input:

13 5
86855 85346
bbaaababbbbbaaaabbbaabbabbabbaabbbabbbbbbbaabaabbaabbaaaabbabaaaabbaaaabababbbbbbbbaabbabababaabaababaaabbabaabaaabaabaabbbabbabbbaabaaaabbbbabbbaabbabaabbabbbaabbbbbaaaaabbbbaaaababbbabaaabaababaababaaabbbaaaababbabaababaabababaababbabbbabaabaaabbabababbbbbbaaaababababbabaabaaaaabb...

output:

23397
496
37520
13084
16191
5015
39198
2818
7676
13149
29388
16788
9755
6909
28102
17426
12692
25730
7138
20353
5086
8739
2658
495
34203
3816
7691
18151
208
26131
7994
21088
3198
3551
17965
13389
12003
1099
4937
2050
9546
461
8972
3718
24214
1105
1631
6965
22150
16897
21692
16809
2538
32409
12849
11...

result:

wrong answer 2nd numbers differ - expected: '497', found: '496'

Test #14:

score: 0
Wrong Answer
time: 315ms
memory: 75896kb

input:

14 5
95651 97657
babbbababaaaabaaaaaaaabbaaabaababbaabbaabbabbaaabababaabaaaabaaaabbbabbabbaaaabbaabbbbbbbbaabbaabbbaaabaaabababbabababbabbbababaabaababbaabbababbbabbbbabbbbabbaaaaabaaaabbabbbabbbabbaababbbabbaaabaabbbbbbbabbabbbabaaaabaaaaaaaababaababbabaaaabaababaababbaaaaababaaabbbbabababbbabaabb...

output:

16666
26260
7301
9219
17849
7041
13588
537
10511
5250
30399
9348
28342
3847
7513
9692
41790
18592
13195
7423
18368
4494
735
9224
201
13124
6892
31857
5055
34072
32148
1798
17635
3487
15848
8096
2947
5926
5118
5355
12682
10065
37287
36556
10885
2817
19447
15735
2004
27802
26892
12199
14431
36471
9213...

result:

wrong answer 5th numbers differ - expected: '17848', found: '17849'

Test #15:

score: 4
Accepted
time: 77ms
memory: 61128kb

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: 245ms
memory: 71944kb

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: 319ms
memory: 74892kb

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: 345ms
memory: 77344kb

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: 75ms
memory: 61240kb

input:

19 5
23197 23286
abbbaabaaabbaabbaaabaabbbabbabbhaabaaabbaabbaaabaabbbabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbbabbabbbaabaaabbaabbaaabaabbaabbambbaabaaabbaabbaaabaabbmabbabbbaabaaabbaabbaaabaahbbabbabbbaabaaabbaabbbaabaabbbabbabbbaabaaabbaabbaaabaabbbabbamb...

output:

1910
2682
1805
4506
5628
1092
2563
4920
2073
2059
437
2768
12
3750
3032
1102
8738
7615
2666
792
3838
5639
3108
4978
97
882
4765
40
673
7203
4568
2555
133
823
164
429
5245
6150
3669
4357
275
5175
2960
5078
5646
372
3912
6780
1678
2850
2623
1167
270
4198
2352
2213
1827
481
8848
2891
4028
10344
6668
18...

result:

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

Test #20:

score: 0
Wrong Answer
time: 165ms
memory: 66320kb

input:

20 5
49694 49669
bbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbaabbbbbbsabbbbbbaabbbbbbaabbbbbbbabbbbbbabbbbbbbaabbbbbbaabbbbbbasbbbbbbaabbbbbbaabbbbbbaa...

output:

13568
1015
5373
9530
1702
1790
27
1977
2444
2430
20681
5763
7262
1051
11897
19152
10707
2552
2221
1555
633
5204
22613
9936
5392
16733
4144
14319
438
1312
20352
5057
6233
221
8659
3362
4789
4205
2192
4612
15382
5465
4255
21897
10085
6412
297
2156
2472
34
767
6937
3402
370
11745
6215
141
1029
2375
25
...

result:

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

Test #21:

score: 0
Wrong Answer
time: 270ms
memory: 72260kb

input:

21 5
74422 74421
baabbllbbaabblabbaabbllbbaabbllbblabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbblbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllbbaabbllpbaabbllbbaabbllbbaabpllbbaa...

output:

8464
12808
14893
15417
2083
15622
4854
25183
3568
9950
10864
455
8984
3496
13291
6664
9956
1378
10603
9952
20961
10716
284
344
677
19333
23365
3210
6242
30
23136
3418
17629
4454
5777
15877
25362
32446
23797
8010
17237
10471
24074
1551
17220
20156
950
15969
319
4415
7360
29545
13604
3148
19988
4775
9...

result:

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

Test #22:

score: 0
Wrong Answer
time: 324ms
memory: 75156kb

input:

22 5
89983 89431
bajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbbzbbaabbzabbjabbaabbajbbazbbaabbzbbbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbjabbaabbajbbazbbaabbzabbja...

output:

11834
4461
9657
10841
25348
5871
5143
8020
8831
7863
14480
386
6540
4570
23182
18628
2242
20331
729
1465
517
21132
32896
12084
10311
27895
26180
7130
2506
34748
4767
9998
1162
17004
5017
248
573
19525
26193
15069
445
109
12045
15342
8018
280
19811
25558
31740
7982
11750
12181
180
9919
19048
14278
30...

result:

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

Test #23:

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

input:

23 5
94783 94700
baabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabavaabaabaaabbaabaaaabaabbaabbaapaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaaabaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaabbaabbaabaaaabaabbaaabaabaaaabaabaaabbaabaaaabaabbaabbaabaaaabaa...

output:

8011
2003
11759
26951
10325
14084
36029
9183
29676
9946
26252
3343
1335
4303
3824
937
29512
20418
13019
2470
14558
8892
15585
216
761
8787
3047
10307
15464
1153
7873
9737
11319
13
1843
8595
270
3100
14912
2024
8293
1531
6940
541
2842
16565
2032
26661
37540
3138
31235
5555
3331
2908
1758
7852
5844
27...

result:

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

Test #24:

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

input:

24 5
99576 99977
babbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbbabbaabbbabbaabbadbbaabbaabbdabbaabbadbbaabbaabbdabbaabbabbbaabbaabbbabbaabbadbbaabbaabbdabbaabbad...

output:

25233
22884
4203
25967
30497
8682
15592
4264
21
-2
678
3536
18270
721
29246
5671
2310
34069
1094
2150
1225
17811
26162
308
13480
7902
946
13545
7387
17393
16706
13914
4719
35022
5761
16847
1660
3850
5422
13560
7243
925
39105
2834
1102
13497
20012
19225
16485
4065
1263
16431
552
13228
11878
16007
191...

result:

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

Test #25:

score: 0
Wrong Answer
time: 370ms
memory: 78308kb

input:

25 5
99821 99309
aabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbbabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaxbbaabbaabbaabbxabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbabbbaabeaabbaab...

output:

9300
10235
15505
4882
29725
9458
6164
10276
13792
30281
4376
12582
23522
10308
1237
14621
18815
3747
8899
7650
2497
27158
3513
12915
14121
24133
19
968
4126
15315
1062
3218
5256
322
32582
182
5351
15125
7338
5493
20823
1605
7633
17280
9822
9695
264
2996
502
33951
5003
2405
13469
1886
814
7458
27100
...

result:

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