QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#221357#6844. Suffix AutomatonrealIyxiang#AC ✓3118ms293944kbC++144.0kb2023-10-21 12:47:112023-10-21 12:47:11

Judging History

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

  • [2023-10-21 12:47:11]
  • 评测
  • 测评结果:AC
  • 用时:3118ms
  • 内存:293944kb
  • [2023-10-21 12:47:11]
  • 提交

answer

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e6 + 10;

int q, n;
char s[N];
int sa[N], rk[N << 1], ork[N << 1], px[N], id[N], ht[N], cnt[N], m;

priority_queue < pair < ll, int >, vector < pair < ll, int > >, greater < pair < ll, int > > > ques;

using namespace __gnu_cxx;
using namespace __gnu_pbds;

ll tot;

tree < pii, null_type, less < pii >, rb_tree_tag, tree_order_statistics_node_update > t;

vec lim[N], del[N];
pii ans[N];

void ins(int l, int r) { if(l <= r) t.insert({ l, r }); }

void cut(int x) {
	auto it = t.upper_bound(pii{ x, n + 1 });
	if(it == t.begin()) return; it--;
	int l, r; tie(l, r) = *it;
	if(l <= x && x <= r) {
		t.erase(it);
		ins(l, x - 1), ins(x, r);
	}
}

void rem(int x) {
	auto it = t.upper_bound(pii{ x, n + 1 });
	if(it == t.begin()) return; it--;
	int l, r; tie(l, r) = *it;
	if(l <= x && x <= r) {
		t.erase(it);
	//	cerr << " ! REM " << x << " " << l << " " << r << endl;
		ins(l, x - 1), ins(x + 1, r);
	}
}

int st[21][N], lg[N];

int qmin(int l, int r) {
	int k = lg[r - l + 1];
	return min(st[k][l], st[k][r - (1 << k) + 1]);
	int x = sa[l]; rep(i, l, r) chkmin(x, sa[i]);
	return x;
}

int get(int rk) {
	//cerr << rk << " " << t.size() << endl;
	auto it = t.find_by_order(rk - 1); assert(it != t.end());
	int l, r; tie(l, r) = *it;
	return qmin(l, r);
}

int main() {
#ifdef YJR_2333_TEST
	freopen("1.in", "r", stdin);
#endif
	scanf("%s",s+1); n = strlen(s+1); m = 300;
	for(int i = 1;i <= n;i++) ++cnt[rk[i]=s[i]];
	for(int i = 1;i <= m;i++) cnt[i] += cnt[i-1];
	for(int i = n;i >= 1;i--) sa[cnt[rk[i]]--] = i;
	for(int h = 1,p;h <= n;h<<=1,m = p){
		p = 0;for(int i = n;i > n-h;i--) id[++p] = i;
		for(int i = 1;i <= n;i++) if(sa[i] > h) id[++p] = sa[i] - h;
		for(int i = 1;i <= m;i++) cnt[i] = 0;
		for(int i = 1;i <= n;i++) ++cnt[px[i] = rk[id[i]]];
		for(int i = 1;i <= m;i++) cnt[i] += cnt[i-1];
		for(int i = n;i >= 1;i--) sa[cnt[px[i]]--]=id[i];
		for(int i = 1;i <= n;i++) ork[i] = rk[i];
		p = 0;
		for(int i = 1;i <= n;i++)
			rk[sa[i]] = (ork[sa[i-1]] == ork[sa[i]] && ork[sa[i-1] + h] == ork[sa[i] + h]) ? p : ++p;
	}
	rep(i, 1, n) st[0][i] = sa[i];
	rep(i, 2, n) lg[i] = lg[i >> 1] + 1;
	rep(i, 1, 20) rep(j, 1, n) st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
	int j = 0;
	rep(i, 1, n) {
		if(rk[i] == 0) continue;
		if(j > 0) j--;
		while(s[i + j] == s[sa[rk[i] - 1] + j]) j++;
		ht[rk[i]] = j;
		lim[j + 1].eb(rk[i]);
	}
	rep(i, 1, n) del[n - i + 1].eb(rk[i]);
	t.insert({ 1, n });
	q = in; rep(i, 1, q) { ll k = lin; ques.ep(k, i); }
	/*
	rep(i, 1, n) cerr << sa[i] << " "; cerr << endl;
	rep(i, 1, n) cerr << ht[i] << " "; cerr << endl;
	*/
	rep(len, 1, n) {
		//lim
		for(auto v : lim[len]) cut(v);
		/*
		cerr << "!" << len << endl;
		for(auto v : t) cerr << v.fi << " " << v.se << endl;
		*/
		ll cur = t.size();
		while(ques.size() && ques.top().fi - tot <= cur) {
			int x = ques.top().se; ll ret = ques.top().fi; ques.pop();
			ans[x].fi = get(ret - tot), ans[x].se = ans[x].fi + len - 1;
		} tot += cur;
		//del
		for(auto v : del[len]) rem(v);
	}
	rep(i, 1, q) {
		if(ans[i].fi == 0) ans[i].fi = ans[i].se = -1;
		printf("%d %d\n", ans[i].fi, ans[i].se);
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 112496kb

input:

ccpcguilin
5
1
10
4
8
26

output:

1 1
2 3
8 8
1 2
4 7

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 8ms
memory: 110456kb

input:

banana
3
5
10
16

output:

1 2
2 5
-1 -1

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 112464kb

input:

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
1000
752
397
968
637
706
758
780
574
1032
599
431
1038
700
868
252
1084
813
277
565
112
69
997
222
897
931
75
200
360
698
196
31
971
1064
591
485
179
528
71
45
422
272
925
8
197
796
116
187
983
1057
939
...

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 69
-1 -1
-1 -1
-1 -1
-1 -1
1 75
-1 -1
-1 -1
-1 -1
-1 -1
1 31
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
1 71
1 45
-1 -1
-1 -1
-1 -1
1 8
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 7ms
memory: 112512kb

input:

ywyywywwywwywwwwwywwyyyywywywyyywywwywwwwwyyyyywwwwwwwywwwwwwwywyywwywwyyywwyyyyyyywyyyyyyywwy
1000
1545
1728
2068
3537
4585
3752
2495
3165
4342
4441
4109
4219
1709
3238
2946
1807
2717
4494
888
1956
1317
1508
3494
3945
3261
3892
1299
3903
2293
4055
218
3263
2265
793
4043
3851
2551
1478
1371
4015
267...

output:

26 50
17 44
32 64
30 94
-1 -1
8 81
51 91
19 73
-1 -1
-1 -1
-1 -1
-1 -1
52 79
10 66
10 59
9 37
8 52
-1 -1
44 59
44 74
47 68
35 59
20 83
1 87
4 60
9 90
41 62
12 94
27 63
-1 -1
4 11
26 82
56 92
24 38
-1 -1
6 84
39 80
28 51
19 41
-1 -1
17 60
59 89
40 56
22 56
-1 -1
62 78
57 84
27 49
12 17
11 32
56 82
34...

result:

ok 1000 lines

Test #5:

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

input:

pcfppcppppppffpppfffppfpfpffpfcffccffcfpcpfcfcfcppppfcppcccfffpffpfppffffcffffpfcpcpffppppff
1000
4871
1081
4356
3107
4567
4525
1585
3772
3802
3762
4827
3359
1004
511
4521
2924
4765
3146
2038
2652
3847
1381
1652
1000
4241
2288
4668
4396
4830
437
879
524
2346
4535
425
3738
2249
652
4865
1523
4014
303...

output:

-1 -1
30 46
-1 -1
20 70
-1 -1
-1 -1
54 77
11 82
19 92
13 84
-1 -1
34 91
30 45
59 68
-1 -1
18 64
-1 -1
25 76
58 88
51 91
11 86
47 67
2 26
6 21
-1 -1
54 88
-1 -1
-1 -1
-1 -1
43 51
1 14
73 82
48 83
-1 -1
35 43
18 88
23 56
22 32
-1 -1
53 75
-1 -1
26 74
27 88
35 84
72 84
9 83
1 83
-1 -1
1 27
60 77
31 47
...

result:

ok 1000 lines

Test #6:

score: 0
Accepted
time: 3ms
memory: 112520kb

input:

wejweujeuuweuweweuwwuwjwuuweeejwwujeeuujjeujjwwejejejwuewewuwjeejeejwuuwwuujuuueujeeueejuuu
1000
2184
2550
3992
3956
328
588
4911
3085
4725
974
4880
4674
2769
4546
662
4159
3161
3465
1310
2431
2018
4349
1057
919
767
3513
1844
3671
4385
3792
2031
180
1921
3576
3386
419
2162
3607
2108
308
1613
1681
20...

output:

11 42
15 53
-1 -1
4 90
42 48
82 91
-1 -1
39 88
-1 -1
67 81
-1 -1
-1 -1
38 80
-1 -1
8 18
-1 -1
3 54
14 73
70 88
50 86
50 79
-1 -1
12 27
23 36
34 45
23 84
49 75
17 84
-1 -1
11 83
62 91
23 27
6 33
13 76
6 63
56 63
53 84
1 65
39 69
46 51
33 55
54 77
24 52
55 62
45 73
44 57
9 84
43 75
23 58
18 79
5 63
5 ...

result:

ok 1000 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 112524kb

input:

wwhceznchkxaapvubwijfxcgyvqywqdoaizsoxlisttlszxwdhcrsmeznsfaldsnbwzxushrmcchhozkrasgnzpsvquthrrh
1000
3471
1192
980
2224
2431
3259
1439
2079
4858
931
3569
4572
1808
1651
1485
1346
3786
3803
2499
2748
5241
4136
1871
2465
1979
3027
264
4165
2885
4512
3061
4578
3724
5154
5258
289
3620
2197
505
4355
238...

output:

32 81
55 69
36 47
47 74
35 65
51 96
50 67
1 26
-1 -1
4 15
36 87
3 96
65 87
46 65
22 39
23 39
15 71
23 80
33 65
12 48
-1 -1
29 95
28 50
57 88
44 68
1 41
70 73
29 96
40 78
4 89
44 85
-1 -1
31 86
-1 -1
-1 -1
68 71
15 67
37 64
3 9
9 84
24 54
-1 -1
4 71
39 84
53 60
10 68
8 23
42 51
14 56
-1 -1
62 95
53 5...

result:

ok 1000 lines

Test #8:

score: 0
Accepted
time: 3ms
memory: 112388kb

input:

fylqobffxudwaqylowoinlqxzvrkswrmdjjnxymspxfxqkjccxzlrunqenyuvflyqfedfwyxrymuvmgmrazceolhdknvxldmk
1000
824
5124
1712
3832
570
3344
4775
3672
3208
4320
589
4098
1436
4177
4364
4664
3037
4456
5145
1425
2422
2973
2474
1175
2689
4978
463
4299
3826
2843
3948
2859
5378
2303
4565
1672
4641
397
4638
4514
11...

output:

61 70
-1 -1
65 85
36 92
24 30
24 69
-1 -1
10 62
3 46
9 79
89 96
17 80
13 30
15 80
17 89
4 96
35 75
19 95
-1 -1
50 66
63 93
43 82
62 93
72 85
5 39
-1 -1
60 65
6 76
16 72
59 95
22 81
34 71
-1 -1
14 42
14 96
25 44
7 96
25 29
9 97
17 96
37 50
36 94
52 81
9 35
53 58
18 50
-1 -1
32 86
40 55
26 33
-1 -1
35...

result:

ok 1000 lines

Test #9:

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

input:

pnbahlmruoyvhchfbmcpqfrypdbtbagydeldohigazreigkdauhhcvroajpdhfhiclppvtdcheqvuynvyfzujqklahtlftiklbo
1000
4143
5633
2928
1976
4140
5759
5507
3696
4895
2805
5641
3468
4547
4731
5391
802
548
1456
409
228
1221
2962
3931
4272
4060
1173
3633
3297
941
5302
2555
806
3891
5507
5118
2727
4831
2549
3178
2931
1...

output:

5 66
-1 -1
60 97
38 61
13 74
-1 -1
-1 -1
27 78
-1 -1
16 51
-1 -1
18 64
22 96
3 86
-1 -1
13 22
66 72
32 48
17 22
33 36
14 28
43 80
36 92
4 69
40 99
18 31
28 77
5 48
76 86
-1 -1
39 70
61 70
22 77
-1 -1
-1 -1
3 37
3 94
61 92
13 54
34 71
80 98
-1 -1
39 46
-1 -1
3 79
84 86
31 83
15 71
1 60
25 41
13 95
21...

result:

ok 1000 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 108412kb

input:

khnggceactpjxgkkgkmaaennymuudfchyfudhnehrzrwmarmcxeamtkdsrwphgebferyqdghqffxcxvjdcqyxxwrjv
1000
3149
4863
2912
3132
2464
3977
3823
3742
2382
4000
4307
2548
297
4495
2983
2030
3128
3329
1735
2643
3409
2207
376
3706
1305
918
2818
3092
3338
3527
3477
4102
581
560
450
1366
1157
3501
2638
2356
1205
3578
...

output:

23 71
-1 -1
37 80
5 53
3 37
8 89
16 86
24 90
51 84
3 86
-1 -1
7 43
56 60
-1 -1
13 57
61 88
39 87
30 83
27 49
42 79
12 67
22 52
9 14
14 79
67 83
73 84
40 81
17 64
12 65
8 67
12 69
-1 -1
15 22
65 72
84 89
26 43
57 71
7 65
44 81
41 73
2 17
3 63
38 58
51 74
17 88
4 75
58 82
27 28
39 73
77 82
-1 -1
1 2
-...

result:

ok 1000 lines

Test #11:

score: 0
Accepted
time: 490ms
memory: 254228kb

input:

wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...

output:

1 171154
1 828243
1 510784
1 804134
1 683819
1 326398
1 326368
1 906923
1 55858
1 800926
1 411361
1 584101
1 334671
1 321252
1 172896
1 139319
1 362552
1 881890
1 849611
1 724803
1 750804
1 670011
1 698097
1 77487
1 561441
1 144378
1 937646
1 917266
1 960579
1 704659
1 629076
1 872548
1 215439
1 237...

result:

ok 1000000 lines

Test #12:

score: 0
Accepted
time: 536ms
memory: 253696kb

input:

ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss...

output:

1 453459
1 325431
1 985403
1 22031
1 418936
1 962336
1 328894
1 886316
1 23532
1 621350
1 216413
1 652980
1 19591
1 789090
1 442931
1 74176
1 338246
1 516199
1 238878
1 227328
1 667551
1 958351
1 706926
1 956911
1 454973
1 459206
1 486441
1 360451
1 239082
1 61405
1 449730
1 516118
1 266368
1 492024...

result:

ok 1000000 lines

Test #13:

score: 0
Accepted
time: 3068ms
memory: 289652kb

input:

ssqqqqqsssqqqsqsssqqsqsqsssqqsssssqqqqsqssssssqqqqqqqsqssqqsssssqssqqqqsqsqqqqsqsqsqqsqssqsqsqsqsqssqssqqssssqqsssqssssqqsqsqqsqsssqssssqsqqqsqqssssqssssqqsssssqqqqqqqsqqsqsssqssqsqsqssssqsqsqsssqqsqqqqqsssqqqqsssssssssqqsssssqqqssssqsssqqqsqqsqqqsssqqsqsqqqssqqqsqsssqqqsqsqsqsqqssssssqsqqqsqqsqsqsq...

output:

724208 857537
631036 821808
147823 330361
247584 861978
542180 780326
505885 897553
193482 651898
366291 612080
99799 877101
19575 84341
701229 956127
763530 773256
275832 506058
45757 917217
89212 691182
83303 820098
216295 369122
304947 537391
91052 216063
438199 497426
528486 755094
398457 534501...

result:

ok 1000000 lines

Test #14:

score: 0
Accepted
time: 2789ms
memory: 290064kb

input:

mtmttttttmmmtmmmtmtmtttmmmmtmtmmmmmmtmmtmmttmmmtmttmmttmmmmmmmmmtmtttmtttmmtmmttttttttmmmmmtmmmmttmtmttmtmmmtmmttmtttmtttttmmtttmtmmmmmmmtmttmttttmmttmmttmtmtmtmmmmmmtmtmttmmmmtmtttmtmttmmtmmtttmtmmttmtttmtttmmmtmtmttmttmmtttmmmmmtmmtmmmmtttttmtmtmtttttmtmttttmtmmttmtmtmmmmmtmmmmtmmmttmtttmmmmmtmttm...

output:

392374 808678
282286 759391
70161 972520
123813 970400
440302 990380
754957 938058
68048 554289
481198 644746
217223 824323
338587 741365
90306 178505
371748 563534
19271 470812
184628 302314
145590 900010
659644 670546
754837 843323
331821 686534
75566 113613
253023 644136
143758 954999
466009 8392...

result:

ok 1000000 lines

Test #15:

score: 0
Accepted
time: 2863ms
memory: 289420kb

input:

yysssyllyllyyslllsylyllssyssslslyllslyssslsyssllysylyslsslyylysllllyyyssllslsyllsyyllllssllylsylslsylssyssllylyyslllyylysyylyyysysssysllssslsyylllsyylyyyssylssssyslsysyysllyylsylysssyslysylsyllsllyylsysylyllslslslyllylsyslsyslsyyllsllsysllysyysyyllylsllyssyyyslysslslsslyylllsyyyllyysllylyyyyssylyyly...

output:

247840 288756
562857 976941
960680 974610
417203 517266
305165 771141
156374 686413
266967 328675
403058 987150
811347 879930
86971 466536
373773 692611
91766 701184
114721 368969
57144 276983
635114 993181
522470 560476
719066 750366
673546 711778
37842 180087
17500 952998
167040 659969
47986 82540...

result:

ok 1000000 lines

Test #16:

score: 0
Accepted
time: 3042ms
memory: 289280kb

input:

zgzggzlzgglzzgllgzllzlggzgzlgzzlgggglgzzglgggzzzlgggllzzgglgzlgglgllgllllzlggllzggzggzzgzzzzzzllggglzlgzzzlzllgzlgzzzzlzzglggzlgzzllgzgllzgzzzggllzllzggzgggglzlglgzlgzzgggllzzzzggzlzglzlglgggllzgggggzzlzlzzlglzzlzgglzzggzzglzgzlglgglggllggzlzlzglzlzzllzllgzllzlgglzzlzlggzlzllzggglzlglgzzggglglllzlgz...

output:

827620 876764
752784 945478
405352 406826
304393 986115
406375 898844
540985 581508
715538 870473
28125 556107
131145 319757
181628 489548
563756 896965
280273 432748
395311 522296
238918 751975
22632 159073
472157 792301
461836 688472
45136 896563
628845 739120
73982 620832
88818 232862
105488 6537...

result:

ok 1000000 lines

Test #17:

score: 0
Accepted
time: 2824ms
memory: 289344kb

input:

qnnuujjqunujnqnuqnunjuqnjunnjnjjjnnnjujjnjnnnjqunqjujquujqqqnjqquuunuuuqnunqnuqjqnnjnnuujnnnnqujjjnuujjjnqnujqnuquqununqjjunuqnqjunjuqjunnnnjnjjunuqnujnuququnqjjqqunujnqjqqjnjjquqnuqnjqjjquqnqnunnqjjjqquqjnjqnnqqqqqqjnnqnuqnqjnnujjnjunjnjnujnuqjqquujqujuunnuqujjunqqujqnjuqujjujjunqqjunuujuqujjnjnnjn...

output:

27251 297129
205668 900103
444545 544180
967130 970312
399426 793200
162463 845329
341499 703426
19264 888830
363449 626492
375327 839281
833953 942162
310516 516760
424003 826472
599550 634684
382435 755389
42256 704043
102641 997670
251723 628297
259597 747380
670335 854745
448571 589123
165473 85...

result:

ok 1000000 lines

Test #18:

score: 0
Accepted
time: 2891ms
memory: 291396kb

input:

fxooxjfxfjfjxjxfofojjojooxfofoxooojojjjojffoofxofoxjjojfooofjjfjjxojjjxxoxfjofxjxjooojfooxxfxxxjjofxjfofjjoxjjjofjfxxjxxoffjffoojfxjxjooojxxofojfxjfoofjffjfoxffffjoojofxjjxofxfjofoxoxfxjxofxjfxfojofxfjoooooooxxjxojooxfxfxxxfxxofofjxoojoxjjjjjoffjoxojjxxojofxxfjojfojoxooxfjxfjooxjfojjfooofxoxfxjffjjf...

output:

45162 535717
415545 712758
862706 923509
262838 337632
382189 898331
271269 689261
387744 669825
813139 881156
69645 265761
340773 740584
491730 870757
343516 818583
124894 306762
150939 576511
52072 977117
231164 661184
309131 916703
783175 954942
387275 970551
472484 559367
574867 737184
201421 33...

result:

ok 1000000 lines

Test #19:

score: 0
Accepted
time: 3032ms
memory: 291236kb

input:

ammwdatadddwawmattaaddmdawdmdawtddwmmwwwdtwtmdmmmtmdmatmatdatdmwwadwdddtmtmmmawaawmwdmawdmtmtwamdawwdwtwtaamwaadwamdawtatammmtmmmttwtdmtmadmwadmwamdaattwtddtmtwaatwtwattwwtaamwtwdmattwwadataamtaamtmtadddmwdmawwmmtdadwadtdwwatdmwatadddwdmawtttdwtwdwmatdmdwttwwmawtwatwdtwtaaaawattmadmwtwtamwwmmaaamwtw...

output:

295524 813775
67787 589846
761309 823802
279383 516753
660853 751786
261522 328484
711303 782122
155645 274088
394745 667093
570467 709168
92924 170807
18823 590004
83928 293215
325821 505256
573977 708149
32924 327944
217988 882845
171775 818680
320314 660485
505595 980410
725517 838599
1373 648970...

result:

ok 1000000 lines

Test #20:

score: 0
Accepted
time: 3059ms
memory: 289368kb

input:

zgfznzfpnggfpnnzzzggnfpzgznpnpzppfnfggpgzgppzzgznnfnfzzppnpfgnfzfnzgpggznfzpzfpnppfgppzpgggggpzfpzgnngnnfngpppppggznpfzznpzpnnnffppnffgfzpnffzfnzppzfgfnfngzppzzzfppzpngfzzzzggzpgpzfzgpgpzpfgpffgfzfnpngnzgznggppgzpfnfngnpppzggpgnzgnfgfppngpgzzgngngfpzfnpfnnznfnpzgfngfzgngngpnzgfnpnzgpppznggpznpzzgfpn...

output:

298915 797306
106153 442383
15904 281881
876965 894056
229861 737464
334355 893248
711560 931887
525557 657882
1566 121135
112651 338248
2711 688248
65278 511925
15293 402790
416402 982146
439037 661602
179008 543897
368669 693983
216121 625061
29382 851802
642451 817205
20145 33924
276618 873171
13...

result:

ok 1000000 lines

Test #21:

score: 0
Accepted
time: 2890ms
memory: 292456kb

input:

jdszvwszwbdedzgsbdovzeggnnqbzbxodgwnvwxweqqqnnoowvjgwxewdoqexzvojbxwwosdvxvwdbxjwsnzbqjngqegnvwdovgweqgvvnwnengvnvnzwgodgnnejezsdgqbnbzdzjgjwoeddwewewwvxvsojwdeqexgjeqeoneebwbvbjvojengvwsxqwndnebqqvdqdvbdgqqxnvvzdjgvwzjqxvjwnvgbxjdwojqedqebvdgswqgdwozbssjxneqnjdobsxonnqvzxzswxzodjexjdjxsonodzgvdjgxs...

output:

201012 708203
262361 446630
648271 966839
67788 89861
379841 851526
307317 978551
68761 764196
157397 775653
629651 962048
652932 901288
828931 876119
259944 595964
506704 631038
176995 413830
179867 326265
134308 902122
534972 586094
89176 261361
99845 633294
190008 512629
122503 747805
38384 77334...

result:

ok 1000000 lines

Test #22:

score: 0
Accepted
time: 3117ms
memory: 291264kb

input:

zyfzxskjesyfhhhfhzyssewywkzfehwshzwzhejjhjhejsjwyyfcwpxppmyzfjfxypxpxmjpmzjhfsphczmmjzhzzxhkppspjjxfcezpfeempxcwcmmxpmfjkysmwxypkkmwzjzypwkwwkzfhhsykmpzceczjjzkjypcjwexfmppkhmfpxxcyjmykkkyfpmmzwkkxewhysjwescjhkekwzwjjmkexhhhppheeemkpmkhsffwhfspppxyywwxpwkxhkkxekzwpmwsmyjfzfmkscfjwxxccwjkxkespmsfwcpk...

output:

244083 982528
82585 911773
30784 640697
638260 789088
286847 430240
768982 875423
126186 859737
527332 667740
737712 841175
296982 340197
139609 637095
208840 621423
115381 839896
220787 753835
587973 962019
328950 372849
833631 910690
250967 503903
48023 463151
756185 771782
430472 447710
397177 59...

result:

ok 1000000 lines

Test #23:

score: 0
Accepted
time: 3064ms
memory: 289308kb

input:

asujdgibqjufdslftiohwfqawzkiowzpjcqjdaaooxbqznxpbzftafabpwfbmgcafoczbhuqljklscozuvmxdwemicmvwesmqdscukojzbmkhcufkbpgmkostuboskjpllzgwhhwjszdcmstnjfgswhogplscxqaihfxwtxmkdkjfelbnjpsehaqpvgbjimlaubjdfjasgjfolamaqovupqwvhsilnczoinjaucavckgwhijdgwjshspksagumltnjlauzeafcbhgjeqhmbuekmiswggfnefwdbeskmmtxin...

output:

235125 404051
321130 702510
227759 706562
209847 975790
201616 754071
383061 564705
265399 612748
77837 458428
528231 899417
482251 841119
511964 807162
338372 376587
402027 728027
751973 780386
418936 972061
668393 761315
93962 439334
173684 642382
832247 839521
758158 821573
201629 558856
606698 8...

result:

ok 1000000 lines

Test #24:

score: 0
Accepted
time: 2902ms
memory: 292380kb

input:

scnmacaccniwcbkwjdbbmdunauveqhfntyritvbuvojkemijhvqmcdyaqsezjokexkkhzetgifsidkohmjqwhchyunejrvmdjnzxwyqmrkoobrmwitdriqiqcbddhfnafegcrtunxhfqbgjwgxemnfgqwstzkdezoiwoktcjqurjiiwkztzediwazvwirrmcwwunoqoxcybwwrsmdycqhonxuucssefkxmwjdjgeixywczeyvvnnrqnrynjxobtavshawnvionuazobzmhavkzmomyxuiajfebmevsigsjws...

output:

748036 951810
481136 884197
297670 646011
593054 725268
651091 882233
781654 960006
784836 915163
703016 722958
373014 416572
618623 894277
289937 784727
723705 998336
845 418515
359499 886397
568384 897968
100842 971179
244468 840223
436563 728662
539682 991476
416164 913170
384597 746617
767870 81...

result:

ok 1000000 lines

Test #25:

score: 0
Accepted
time: 3087ms
memory: 289244kb

input:

jjrcyrxohhbsdaiclcjhngunligvfjhvdahwtqnxlbromwgcqynbgrtxhluvtigdgpdftdnczpfvqmwcgzdmhscbsnvzlwmsbxlgiucupkuhzxjbmardwwjrwgfwdwrjgkgsoocrzoinibqgsdcuhrrbxfpfbjyupuvbunfxurkpaypxdnkbwfwjdqynomiwqyjvbqwstihdctzvkmgjadhfjqkabdypyvhlounsfovzbxfomyddndcbiaiwnzifmosqhqrijffanugdysztcthtwgbqqtnqkzschpbbwfag...

output:

120418 229606
335576 949275
360686 482620
745345 986731
238570 770860
307932 458189
180831 723877
837750 963205
319971 830556
334277 615362
15913 926194
10510 769902
370293 578114
782320 883269
55678 596648
283945 926173
6349 931242
314922 319452
272056 672257
53026 980932
263811 790718
312437 92654...

result:

ok 1000000 lines

Test #26:

score: 0
Accepted
time: 3118ms
memory: 291908kb

input:

qjcommnykbwswfjyasxldtxaffvxcqkclkffhhogevowsqgytylnbbvmbwudamhdwaxnfdhskqfauojeoouvhxwczgbscbszzuvefbuvlywdpckaarpeuqnadkxfafawoagwxdwuadvaopvgpcqdpsowqojzlhcjzjpfxeabsletknneeuzprqahrgvhboqdhakbjnqvqquzvmxsencqvdjfwytxvajcyssomnlxxdvmlknmwcwozwdlssxkvyvfvjbyvkucchnmwhbzygblfckqcraynbxvlktfusggzgap...

output:

94333 680827
592541 917376
760420 932957
551816 683605
203044 339600
292833 561857
56658 69987
778185 882128
455517 790454
279472 545281
473304 644542
429143 480029
704125 864434
247229 444839
293855 336937
23716 372564
725637 998786
199682 454744
44207 699981
131928 852466
486213 723656
85636 37266...

result:

ok 1000000 lines

Test #27:

score: 0
Accepted
time: 2873ms
memory: 293944kb

input:

gajsczqwxupcalffxdcwnqzzwxkthrpbjtxsqrhgqtkelztbrqxsllegwqbwppmsgjhwmggkevrbwnerrcshghxvfwckwjizhmiyiijxlzkwpuwsjdddenosrbsxtlxuxxsgfarjiiflmiynwezbjkukbsspkipxcjfjrnsunzzrquglypqhyjpzprcwbrikhfmtntgrtatdjhqgmizfbmvgcrzpeywrjstuyqjdggkheienfpiguxzupqlhwnqgwawaqszsaclsfsbqwgqbhhipjsvdoefloxnsqbtlrxug...

output:

909412 989928
218599 952637
17603 909846
139657 448106
463538 992749
631938 747493
100660 111909
116002 148063
126240 829661
342367 628496
340868 427147
325346 691345
886445 973104
15414 943640
909368 951042
154441 754231
639860 981643
467248 936448
274883 312673
55632 673044
36836 67246
119698 1295...

result:

ok 1000000 lines

Test #28:

score: 0
Accepted
time: 3102ms
memory: 289856kb

input:

pkzrxeiunfunjzusutpqfatcwwwdhbukdtqsvclraptfjfqzbwcmyxnhszcajvltqzhnyqybpguqufmpxgkkoiunppdimtfjjpnfjfofpwnuzmzqjqiqzpdaktrztwxafqlpupnosylqebgrnspioobgeklzfimjdaoqmnoblhxasompxfdtyokajqswydiwesroitdvgvmjjvrxrkqbepyhftraiqogjgaaqjqjzkvspczmfkozbcgujvblcuqedmtutipgbnlabplzhrlmuzgwdzhcpzzyqwbbvamendle...

output:

682973 702799
222811 285161
824451 875370
528739 678864
606635 715950
218478 757806
94841 98783
370626 632541
704068 882630
155891 552100
332032 764325
784338 907770
488717 626425
224647 986658
456786 601637
534824 997124
302669 742427
667431 899728
268211 949371
66956 937445
713265 856069
7209 7662...

result:

ok 1000000 lines