QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240872#6844. Suffix AutomatonSylviallineAC ✓873ms150188kbC++233.1kb2023-11-05 20:27:432023-11-05 20:27:44

Judging History

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

  • [2023-11-05 20:27:44]
  • 评测
  • 测评结果:AC
  • 用时:873ms
  • 内存:150188kb
  • [2023-11-05 20:27:43]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll=long long;
inline int qlog(double x){
    return ((*(long long*)&x)>>52&2047)-1023;
}
void solve();
int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cout.tie(nullptr);
	int t=1;
	// cin>>t;
	while(t--)solve();

}


const int N=1e6+3;
int sa[N],rk[N],hgt[N];
string s;
void get_sa(int n){
    static int sb[N],cnt[N],rk_[N];
    int i,j,k=26,m;
    int *rko=rk_,*rkn=rk;
    for(i=1;i<=n;i++)cnt[s[i]-'a'+1]++;
    for(i=2;i<=k;i++)cnt[i]+=cnt[i-1];
    for(i=n;i;i--)sa[cnt[s[i]-'a'+1]--]=i;
    for(i=1,k=0;i<=n;i++)rkn[sa[i]]= k+=s[sa[i]]!=s[sa[i-1]];
	// cout<<"???"<<k<<endl;
    for(m=1;k<n;m<<=1){
		// cout<<"$"<<m<<" "<<k<<endl;
        for(i=1;i<=m;i++)sb[i]=n-m+i;
        for(j=1;j<=n;j++)if(sa[j]>m)sb[i++]=sa[j]-m;
        
        swap(rko,rkn);
        for(i=1;i<=k;i++)cnt[i]=0;
        for(i=1;i<=n;i++)cnt[rko[i]]++;
        for(i=2;i<=k;i++)cnt[i]+=cnt[i-1];

        for(i=n;i;i--)sa[cnt[rko[sb[i]]]--]=sb[i];
        for(i=1,k=0;i<=n;i++)rkn[sa[i]]= k+=rko[sa[i]]!=rko[sa[i-1]]||rko[sa[i]+m]!=rko[sa[i-1]+m];
    }
    if(rkn!=rk)memcpy(rk+1,rk_+1,n*4);
}

void get_hgt(int n){
    for(int i=1,k=0;i<=n;i++){
        for(k-=k>0;s[i+k]==s[sa[rk[i]-1]+k];k++);
        hgt[rk[i]]=k;
    }
}

ll sum[N];
int ans[N][2];
int f[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
struct BIT{
	int b[N],n;
	void modify(int x,int d){
		for(;x<=n;x+=x&-x)b[x]+=d;
	}
	int bin(int k){
		int nw=0,s=0;
		for(int p=1<<qlog(n);p;p>>=1){
			if((nw|p)<=n&&s+b[nw|p]<k)s+=b[nw|=p];
		}
		// if(s!=k)puts("ERROR!!");
		return nw+1;
	}
	// int query(int x){
	// 	int t=0;
	// 	for(;x;x&=x-1)t+=b[x];
	// 	return t;
	// }
	// void display(){
	// 	cout<<"B:"<<endl;
	// 	for(int i=1;i<=n;i++){
	// 		cout<<query(i)-query(i-1)<<" ";
	// 	}
	// 	cout<<endl;
	// }
}B;
void solve(){
	cin>>s;
	int n=s.size();
	s='#'+s;
	get_sa(n);get_hgt(n);
	// cout<<"SA:"<<endl;
	// for(int i=1;i<=n;i++)cout<<sa[i]<<" ";cout<<endl;
	// cout<<"RK:"<<endl;
	// for(int i=1;i<=n;i++)cout<<rk[i]<<" ";cout<<endl;

	vector<vector<int>>H(n+1);
	for(int i=1;i<=n;i++)H[hgt[i]].push_back(i);
	for(int i=1;i<=n;i++)sum[hgt[i]+1]++;
	for(int i=1;i<=n;i++)sum[i+1]--;
	for(int i=1;i<=n;i++)sum[i]+=sum[i-1];
	for(int i=1;i<=n;i++)sum[i]+=sum[i-1];
	// cout<<"SUM:"<<endl;
	// for(int i=1;i<=n;i++)cout<<sum[i]<<" "<<endl;
	int q;cin>>q;
	vector<vector<pair<int,int>>>Q(n+1);
	for(int i=1;i<=q;i++){
		ll k;cin>>k;
		if(k>sum[n]){
			ans[i][0]=ans[i][1]=-1;
			continue;
		}
		int p=lower_bound(sum+1,sum+n+1,k)-sum;
		Q[p].emplace_back(k-sum[p-1],i);
	}

	for(int i=1;i<=n;i++)f[i]=i;
	B.n=n;
	// cout<<"$?"<<endl;
	// B.display();
	for(int i=n;i;i--){
		B.modify(rk[n-i+1],1);
		for(auto w:H[i]){
			int x=getf(w),y=getf(w-1);
			if(sa[x]>sa[y])f[x]=y,B.modify(x,-1);
			else f[y]=x,B.modify(y,-1);
		}
		// B.display();
		for(auto &[k,p]:Q[i]){
			// cout<<"!"<<k<<" "<<p<<" "<<B.bin(k)<<endl;
			ans[p][0]=sa[B.bin(k)];
			ans[p][1]=ans[p][0]+i-1;
		}
	}
	for(int i=1;i<=q;i++)cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
}

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

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 21988kb

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: 0ms
memory: 21972kb

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: 21984kb

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: 0ms
memory: 22144kb

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: 3ms
memory: 22060kb

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: 22060kb

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: 22052kb

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: 0ms
memory: 22120kb

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: 0ms
memory: 22056kb

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: 3ms
memory: 22304kb

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: 616ms
memory: 150092kb

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: 654ms
memory: 150188kb

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: 817ms
memory: 122064kb

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: 844ms
memory: 122032kb

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: 800ms
memory: 122168kb

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: 813ms
memory: 121816kb

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: 830ms
memory: 121888kb

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: 844ms
memory: 121904kb

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: 840ms
memory: 121764kb

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: 873ms
memory: 121776kb

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: 841ms
memory: 122864kb

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: 829ms
memory: 122312kb

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: 834ms
memory: 122380kb

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: 800ms
memory: 122884kb

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: 838ms
memory: 123080kb

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: 838ms
memory: 122180kb

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: 812ms
memory: 122228kb

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: 820ms
memory: 123048kb

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