QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#703756#8073. StringNightskyAC ✓110ms140876kbC++144.2kb2024-11-02 18:25:362024-11-02 18:25:36

Judging History

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

  • [2024-11-02 18:25:36]
  • 评测
  • 测评结果:AC
  • 用时:110ms
  • 内存:140876kb
  • [2024-11-02 18:25:36]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define fi first
#define se second
#define mkp make_pair
#define pb push_back
typedef pair <int, int> pii;

inline int read() {
	int x = 0, f = 0;
	char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = 1; c = getchar();}
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c & 15), c = getchar();
	return f? -x : x;
}

const int MAXN = 2e5;

struct SEG {
	int tot;
	int lc[MAXN*40+10], rc[MAXN*40 + 10], sum[MAXN*40+10];
	inline void pushup(int s) {
		sum[s] = sum[lc[s]] + sum[rc[s]];
	}
	void upd(int l, int r, int x, int v, int &s) {
		if (!s) s = ++tot;
		if (l == r) {sum[s] += v; return;}
		int mid = l + r >> 1;
		if (x <= mid) upd(l, mid, x, v, lc[s]);
		else upd(mid + 1, r, x, v, rc[s]);
		pushup(s);
	}
	int query(int l, int r, int L, int R, int s) {
		if (R < l || L > r || !s) return 0;
		if (L <= l && r <= R) return sum[s];
		int mid = l + r >> 1;
		return query(l, mid, L, R, lc[s]) + query(mid + 1, r, L, R, rc[s]);
	}
	int merge(int s1, int s2) {
		if (!s1 || !s2) {return s1 + s2;}
		int s = ++tot;
		lc[s] = lc[s1], rc[s] = rc[s1];
		sum[s] = sum[s1] + sum[s2];
		//if (l == r) return s;
		lc[s] = merge(lc[s1], lc[s2]);
		rc[s] = merge(rc[s1], rc[s2]);
		pushup(s);
		return s;
		//pushup(s);
	}
}seg;

namespace SAM {
    const int MAXS = MAXN*2;
	/*
	struct node{
		int x, p, v;
		inline node() {}
		inline node(int x_, int p_, int v_) {return x = x_, p = p_, v = v_;}
	};*/
    struct SAM {
        vector <int> G[MAXS];
        int ch[MAXS][28];
        int len[MAXS], sum[MAXS], fa[MAXS], rt[MAXS], last, tot;
        int extend(int c) {
            int np = ++tot, p = last; last = np;
            len[np] = len[p] + 1; sum[np] = 1;
            for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;
            if (!ch[p][c]) {
                ch[p][c] = np;
                fa[np] = p;
                return np;
            }
            int q = ch[p][c];
            if (len[q] > len[p] + 1) {
                int nq = ++tot; len[nq] = len[p] + 1; fa[nq] = fa[q];
                for (int i = 0; i < 26; ++i) ch[nq][i] = ch[q][i];
                fa[np] = fa[q] = nq;
                for (; ch[p][c] == q; p = fa[p]) ch[p][c] = nq;
            }
            else fa[np] = q;
            return np;
        }

        int dfn[MAXS], siz[MAXS], tt;
        void dfs1(int x) {
            dfn[x] = ++tt; siz[x] = 1;
            for (auto v : G[x]) {
                dfs1(v);
				rt[x] = seg.merge(rt[x], rt[v]);
                siz[x] += siz[v];
				sum[x] += sum[v];
            }
		//	cerr << seg.query(1, s2.tt, s2.dfn[4], s2.dfn[4], rt[1]) << " ";
        }
        void build() {
            for (int i = 1; i <= tot; ++i)
                G[fa[i]].pb(i);
            dfs1(0);
        }
    };
}
SAM :: SAM s1, s2;

char s[MAXN + 10], t[MAXN + 10];
int pos1[MAXN + 10], pos2[MAXN + 10];

int main() {
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	int n = strlen(s + 1);
	int m = strlen(t + 1);
	for (int i = 1; i <= n; ++i)
		pos1[i] = s1.extend(s[i] - 'a');
	for (int i = m; i >= 1; --i)
		pos2[i] = s2.extend(t[i] - 'a');
	s2.build();
	for (int i = 1; i <= n; ++i) {
		seg.upd(1, s2.tt, s2.dfn[pos2[i + 1]], 1, s1.rt[pos1[i]]);
		if (pos2[i + 1] == 4) {
			//cout << pos1[i] << " " << pos2[i + 1] << endl;
		}
	}
	//cerr << seg.query(1, s2.tt, s2.dfn[4], s2.dfn[4], s1.rt[4]) << endl;
	s1.build();
	//cerr << seg.query(1, s2.tt, s2.dfn[4], s2.dfn[4], s1.rt[7]) << endl;
	int Q = read();
	while (Q--) {
		static char str[MAXN + 10];
		static int p1[MAXN + 10], p2[MAXN + 10];
		scanf("%s", str + 1);
		int len = strlen(str + 1);
		int now1 = 0, now2 = 0;
		for (int i = 1; i < len; ++i) {
			now1 = p1[i] = s1.ch[now1][str[i] - 'a'];
			if (!now1) break;
		}
		for (int i = len; i > 1; --i) {
			now2 = p2[i] = s2.ch[now2][str[i] - 'a'];
			if (!now2) break;
		}
		ll ans = 0;
		for (int i = 1; i < len; ++i) {
			int p = p2[i + 1];
			if (!p1[i] || !p) continue;
			int res = seg.query(1, s2.tt, s2.dfn[p], s2.dfn[p] + s2.siz[p] - 1, s1.rt[p1[i]]);
			ans += res;
		//	cerr << res << " ";
			}
		printf("%lld\n", ans);
		for (int i = 1; i <= len; ++i) p1[i] = p2[i] = 0;
	}
	return 0;
}



詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 38592kb

input:

aaababaa
aababbca
7
aa
abb
aab
ab
abc
bb
ba

output:

3
1
3
2
2
1
0

result:

ok 7 lines

Test #2:

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

input:

baabaabbaaaaabaabbababababaabbaababaaababbbabbabaa
aabaabaabbbbbabaababbbbaaabbbaabaabaabbbabbabbbbab
10
bb
abaaa
aabb
aab
bb
ba
bba
bab
baa
abba

output:

11
4
10
11
11
11
8
19
8
10

result:

ok 10 lines

Test #3:

score: 0
Accepted
time: 102ms
memory: 138896kb

input:

aababbababaaaaaabbababaaabbabbbbbbaaabbbbaaabaabaaabaaaabbbabababaaabbababbbaaaabbbbbaabaaababbaaaaaaabaabaabaabbbbbbaabbbabababbabbbbabbabababaaaabaaaaabbbbaababbbbaaabbbbbaabaabbaababbaaabaabaaabbbbaabababaaabbbbabaababababbbaababbabbbbbbabbbbaaabbaaabbbabbabaabbaaabaaaabbbbbbbaabaabbbbbbabbbbabbb...

output:

7767
7715
909
1491
2808
4622
4678
911
1652
4693
854
7763
1579
7833
903
845
7878
4658
891
4721
2709
7835
896
4643
2748
7870
7795
1574
4577
4777
7767
4683
7652
7833
844
7715
7713
4577
2791
839
4657
4693
2781
890
2706
4839
2804
7745
4717
4629
871
4704
4694
845
938
4709
921
2629
1573
2577
1552
1570
2735...

result:

ok 10000 lines

Test #4:

score: 0
Accepted
time: 107ms
memory: 140876kb

input:

abbbbbbbbabbbbbbabbbbbbbbbbbbbbabbbbbbbabbbbbbbbababbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaabbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbaababbbbbbbbbbabbabbbbabbbbbbbbbbbbbbbbbbbbbbbbaabbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbabbbbbabbbab...

output:

34850
31846
329
401
3814
34948
33612
3183
361
266595
29417
302399
302399
32019
266595
302399
302399
31846
35131
417
29417
29518
266595
34288
29518
287986
287986
34389
315008
3547
3538
302399
33730
266595
287986
29417
33467
311153
3901
287986
32019
35094
266595
315008
311153
3674
266595
33467
266595
...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 67ms
memory: 140560kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

557438
643590
643590
810239
469439
557438
810239
727850
643590
557438
7951
810239
469439
727850
469439
727850
469439
643590
643590
810239
643590
8501
469439
6737
557438
810239
810239
810239
557438
469439
557438
469439
810239
727850
810239
8910
643590
810239
643590
810239
810239
643590
643590
727850
...

result:

ok 10000 lines

Test #6:

score: 0
Accepted
time: 55ms
memory: 137180kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

30332
0
313061608
29671
0
0
0
314370702
319012593
33652

result:

ok 10 lines

Test #7:

score: 0
Accepted
time: 88ms
memory: 134064kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

34853112
36299
40248
33664728
38863
0
0
38064
796
34862762
34709168
0
34621745
34495725
34294358
0
34841561
0
36683
40286
33960688
40111
34701284
33140841
33770
0
40154
0
34180679
34654709
40663
40135
34536818
38227
34228418
34365767
0
0
35763
37936
34565447
34835037
34479707
38864
33664728
37636
34...

result:

ok 100 lines

Test #8:

score: 0
Accepted
time: 88ms
memory: 110368kb

input:

uerusvmzbugopnwcvdqnubfjhztzqskhsvxdphbiwltiyttphztkrhxqdfuqrlxdehenhtvogyqeilhgexsoafhsjcctjkjbpqsyosjefzcepgpatrfbmpoqgkngqfejugupbkeisszlckpaqhdbxipzmngcoynandwjnqlultpesmpzvtcnaqeeclazmoblypsmwzwrcwizumbnyrdsibhydeplvrmkyghizudojhqswvajsskrxwofxsnvfwyjqipxtwtbzsumijxyvptuqsekwpkuvmqzpkchaxissqlz...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 lines

Test #9:

score: 0
Accepted
time: 99ms
memory: 118164kb

input:

ggfhhdbgjfagabaabjjcibcbcifgjcigjjjgdajfeegejdffgihgchdjjbhchdbcjhecjggfjcfdahbcbjejeggiddjfjcegifbifjggeciiifhfeehjcgebfgefdhejgfijddedgccebbibadjedagebedbbgibjdefjfgfhagjabeiiajbhgdggfihhfbdihdgeciaejhbdegbcjjbfgdiigecdbifdjhbcijddbijeibbbacgbdbfejajhdaajfejidibbciehjaabjbdiihfggdedjfbbdeifbijahih...

output:

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

result:

ok 10000 lines

Test #10:

score: 0
Accepted
time: 101ms
memory: 124716kb

input:

baedbcceddedebadcecccbbbcaeecacaecbdcacdeebeedacbabaecdcbeacbaceebbbadbedbaaeebeadbeebaeaaaabbcdecabdbabadcbcbadcbecabcdedecaaedeadcadebadbedacceabcecabcaaceceedaaedddeababcbcceedcaedcbcadebdcabebadbeadcbbadaeedebeabbbbceccceabedcabebbaebccdcceacccbeddabacdcdddbabedaadbadeccaaccddbecbbacdcaedaaeacae...

output:

29
127
0
0
1
1
8
0
23
142
0
3
0
0
0
0
1
4
29
0
122
0
12
25
1
6
7
37
6
26
0
114
0
0
140
4
2
127
1
0
0
36
0
2
8
0
3
129
26
46
3
0
10
145
34
150
0
3
0
25
13
10
0
132
32
119
1
3
0
7
6
5
40
5
36
140
1
28
0
1
0
0
0
136
123
122
109
120
3
124
116
8
130
8
133
124
4
6
146
0
38
0
0
1
0
0
28
0
1
36
2
123
2
1
1
...

result:

ok 10000 lines

Test #11:

score: 0
Accepted
time: 110ms
memory: 129972kb

input:

ccbccbbacabcaaccbcbcabaccaacaccabaaccbacbcaabaaaababcbcacbcccbaccbcaabaabbcacbaaaababbcabcbcabbcabbbccbbbcbbccccababbaacacabbcbcabaaaacbaaacbabcbabaabcbcaaccaaaabbcacacbbbcabcacbcaaabababbbbbbcabcbbabcacbababbaaabcbababbaccbaacbaaccbccacacabcbabaaacbbcabcbaccbcabbaabbbaabcabcbacaccbcbabcbbaaaabbbbab...

output:

1533
15
16
115
88
28
101
302
742
16
1601
1648
1661
8
8
39
40
106
22
717
1636
677
694
1680
1585
36
1653
118
24
661
54
13
681
1677
92
38
96
16
88
672
1616
685
1692
240
35
668
92
21
127
1574
11
33
258
290
22
95
74
129
90
99
707
1597
1677
18
41
278
17
1630
43
33
34
116
20
671
106
1596
258
89
101
18
42
1...

result:

ok 10000 lines

Test #12:

score: 0
Accepted
time: 79ms
memory: 120152kb

input:

myvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdpmyvxrwesifoclqoarxdp...

output:

103
45
150
10
208
48
211
20
50
70
60
200
150
50
120
50
40
198
10
144
20
67
0
50
120
80
221
30
137
160
120
20
90
12
159
60
30
162
40
125
130
204
160
94
40
209
30
20
50
110
37
115
105
212
95
59
210
110
190
205
12
117
190
30
150
36
50
12
60
140
72
153
221
36
153
178
185
140
51
200
86
134
96
10
168
100
...

result:

ok 7891 lines

Test #13:

score: 0
Accepted
time: 64ms
memory: 115384kb

input:

kvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonbkvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonbkvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonbkvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonbkvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonbkvafreigfamumerkwusivmybtnkvajlylqimmzrglwcergnonb...

output:

130
260
207
63
80
2000
230
20
288
50
198
40
190
279
261
150
126
20
351
60
260
234
60
2000
261
279
207
40
351
9
27
160
380
27
306
234
40
198
30
40
261
0
90
180
45
70
144
210
270
50
150
54
360
220
333
40
99
130
30
90
153
162
310
207
72
230
90
90
150
72
380
190
81
81
250
36
144
135
27
180
320
90
333
15...

result:

ok 7865 lines

Test #14:

score: 0
Accepted
time: 81ms
memory: 127300kb

input:

tkfbktlkeiklcblwmlwwktqmtlpwvjjsmxjdkitaswwmyffzadnavriqeteqbeeixhhfeqomcbhsorfeqzxtowkaorfymtbwcmnttkfbktlkeiklcblwmlwwktqmtlpwvjjsmxjdkitaswwmyffzadnavriqeteqbeeixhhfeqomcbhsorfeqzxtowkaorfymtbwcmnttkfbktlkeiklcblwmlwwktqmtlpwvjjsmxjdkitaswwmyffzadnavriqeteqbeeixhhfeqomcbhsorfeqzxtowkaorfymtbwcmnt...

output:

387
160
252
261
0
18
234
315
306
423
441
48
32
324
0
396
171
45
225
369
252
297
171
232
207
184
189
342
297
1270
18
32
117
324
360
27
162
136
414
176
288
216
272
279
104
144
117
99
104
216
1297
306
32
234
336
224
64
261
0
360
351
261
81
432
1189
45
99
225
324
1315
405
315
90
312
288
18
0
117
216
288...

result:

ok 7908 lines

Test #15:

score: 0
Accepted
time: 31ms
memory: 129488kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

599964
499975
699951
499975
499975
499975
899919
899919
499975
399984
799936
899919
599964
799936
699951
699951
699951
899919
799936
499975
399984
599964
499975
599964
899919
399984
699951
399984
899919
699951
599964
699951
499975
699951
799936
499975
599964
399984
499975
499975
899919
699951
799936...

result:

ok 20000 lines

Test #16:

score: 0
Accepted
time: 64ms
memory: 116564kb

input:

puyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvldepuyrrzvlde...

output:

55
10
20
42
40
77
21
21
10
67
77
26
121
88
39
22
50
60
88
50
108
10
22
22
0
24
90
100
80
77
22
44
13
26
40
126
29
50
10
10
13
77
25
105
30
117
0
0
109
33
80
111
96
67
100
101
50
55
66
10
39
125
99
55
99
52
40
124
66
99
55
110
30
80
52
57
18
32
126
60
65
33
112
0
50
110
110
100
11
65
33
66
99
20
109
...

result:

ok 7905 lines

Test #17:

score: 0
Accepted
time: 54ms
memory: 120032kb

input:

fnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlekfnlek...

output:

11
19892
12
10
10
50
40
68
19926
48
40
11
22
66
11
12
19902
20
19926
48
22
11
55
11
20000
40
48
22
22
22
50
19985
19973
0
11
19937
67
55
24
19915
10
19926
44
10
22
44
10
11
26
12
11
0
50
44
30
10
60
22
44
48
19985
22
19959
19959
54
60
0
16
42
55
24
24
42
40
22
55
11
67
44
55
19959
40
55
44
11
44
44
...

result:

ok 7861 lines

Test #18:

score: 0
Accepted
time: 36ms
memory: 119272kb

input:

rzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzorzo...

output:

31
15
11
31
37
33230
33278
33208
12
11
12
31
33175
33186
31
13
10
33266
11
34
37
31
15
34
12
34
37
33278
12
33242
11
11
34
13
33242
31
12
31
16
31
33142
42
31
31
33219
34
33304
28
11
31
12
31
31
31
12
33164
12
31
12
33164
12
11
11
33242
31
31
14
31
33175
11
34
33197
12
11
12
11
31
11
34
31
33278
332...

result:

ok 7801 lines

Test #19:

score: 0
Accepted
time: 24ms
memory: 117124kb

input:

oxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxeoxe...

output:

0
0
33319
0
33318
0
0
33321
0
0
33325
0
0
0
0
0
0
33324
0
0
0
0
0
0
0
0
0
0
33327
0
33331
0
0
0
33327
0
0
33326
0
0
0
0
0
33325
33326
33325
0
0
33326
0
0
0
33331
0
33332
0
0
33326
0
0
0
0
33323
0
0
33330
0
33319
0
33320
33320
0
0
0
0
33320
33317
0
0
33319
0
33331
0
0
0
0
0
0
0
0
0
0
0
33324
0
33329
...

result:

ok 7823 lines

Test #20:

score: 0
Accepted
time: 39ms
memory: 118976kb

input:

yryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryryr...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 7889 lines

Test #21:

score: 0
Accepted
time: 38ms
memory: 124372kb

input:

kvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkvkv...

output:

36
22
33
56
39
44
41
38
22
36
22
35
22
33
22
35
33
22
20
39
33
32
33
33
33
24
33
36
44
36
33
33
44
24
48
33
33
48
33
26
44
44
33
36
22
39
33
30
29
22
33
33
36
24
48
39
44
33
0
29
36
36
33
39
39
24
36
30
56
32
33
41
52
22
29
48
42
33
42
33
33
38
24
22
36
39
33
36
44
20
24
48
22
44
38
22
56
44
41
42
3...

result:

ok 7825 lines

Test #22:

score: 0
Accepted
time: 45ms
memory: 127692kb

input:

dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

3698631
599964
4198236
1199856
0
2799216
2199516
2699271
499975
3398844
2699271
4597884
3898479
99999
4098319
4797696
4398064
499975
999900
2599324
0
1099879
3398844
999900
1899639
299991
3798556
3498775
4398064
3298911
499975
599964
2799216
999900
1899639
799936
2299471
2299471
3398844
199996
99990...

result:

ok 7879 lines

Test #23:

score: 0
Accepted
time: 43ms
memory: 128796kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0
99999
199996
299991
399984
499975
599964
699951
799936
899919
999900
1099879
1199856
1299831
1399804
1499775
1599744
1699711
1799676
1899639
1999600
2099559
2199516
2299471
2399424
2499375
2599324
2699271
2799216
2899159
2999100
3099039
3198976
3298911
3398844
3498775
3598704
3698631
3798556
38984...

result:

ok 600 lines

Test #24:

score: 0
Accepted
time: 43ms
memory: 140500kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

0
99998
199993
299985
399974
499960
599943
699923
799900
899874
999845
1099813
1199778
1299740
1399699
1499655
1599608
1699558
1799505
1899449
1999390
2099328
2199263
2299195
2399124
2499050
2598973
2698893
2798810
2898724
2998635
3098543
3198448
3298350
3398249
3498145
3598038
3697928
3797815
38976...

result:

ok 600 lines

Test #25:

score: 0
Accepted
time: 59ms
memory: 117264kb

input:

teiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteiclteicl...

output:

0
0
0
0
13
14
0
0
0
14
14
0
0
13
0
14
14
0
19986
0
0
0
19986
0
14
14
0
0
14
13
14
13
19986
14
0
19986
0
19986
0
14
0
0
14
0
13
14
13
0
0
14
0
0
14
13
0
19986
0
14
14
13
19986
14
0
14
0
14
13
14
0
14
14
0
0
19986
0
0
14
14
14
0
14
19986
0
14
14
19986
14
0
13
13
14
14
0
0
0
13
13
14
19986
14
13
14
0
1...

result:

ok 133343 lines

Test #26:

score: 0
Accepted
time: 54ms
memory: 127092kb

input:

etzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzseetzse...

output:

45
20009
19911
55
39907
19852
50
50
19936
19842
36
19948
20009
42
19912
55
33
39883
19902
55
50
30
19921
30
30
36
30
39863
19827
19980
55
50
50
19985
30
33
45
39732
19980
19902
19902
19942
19912
39694
39634
19937
20038
27
20009
39885
39774
33
20009
30
33
19981
39863
19832
19852
30
36
50
39609
20011
...

result:

ok 4049 lines

Test #27:

score: 0
Accepted
time: 56ms
memory: 117860kb

input:

vdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgsvdvgs...

output:

0
13
20000
14
20000
20000
13
0
28
0
19986
28
19986
0
40000
26
28
0
0
0
0
14
20000
14
20000
14
14
40000
28
40000
28
14
0
28
14
26
14
0
0
14
19986
28
20000
40000
28
40000
0
40000
28
40000
0
14
28
20000
14
0
19986
14
28
28
0
13
0
0
20000
14
20000
0
26
20000
0
0
28
40000
0
20000
13
28
0
28
26
19986
0
0
...

result:

ok 99798 lines

Test #28:

score: 0
Accepted
time: 39ms
memory: 114908kb

input:

vigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqyvigqy...

output:

32
28
9
8
9
19862
7
19926
19222
65
18
9
9
28
20
40
20
19278
8
18
11
19563
19236
32
19812
16
16
32
16
36
19579
50
20003
19208
8
7
14
19539
32
19822
9
40
19347
9
8
28
8
28
22
18
16
20
24
28
19683
35
8
35
35
18
19619
32
40
19937
9
18
19595
40
19491
36
14
20000
32
14
11
19872
50
32
40
32
16
40
8
16
35
4...

result:

ok 819 lines

Test #29:

score: 0
Accepted
time: 38ms
memory: 121832kb

input:

rmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwprmqwp...

output:

24
18681
7
20
30
15983
4
6
35
16
15935
5
24
20
10
6
30
19985
18429
12
30
20
20
8
12
10
16641
14779
4
16
16
20
24
32
16831
16976
16
28
35
6
5
20
20
10
20
14
35
16
8
15055
30
5
40
4
10
10
16
10
5
16706
16
10
20
20
6
16055
18279
25
4
20
25
17919
18
20
17516
5
20
20
4
20
20
14
40
17746
12
10
14
20
20
6
...

result:

ok 93 lines

Test #30:

score: 0
Accepted
time: 36ms
memory: 117840kb

input:

lgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigjlgigj...

output:

19243
47197
25483
34547
11597
25
4
35199
54483
3
3
18657
5
7
20
13700
39303
5
40
15
36564
16203
20
6
46981
20
25
36594
51068
14371
28810
27187
15
46369
5
28354
38997
16766
56329
3
20
3
25
15519
18781
15
37905

result:

ok 47 lines

Test #31:

score: 0
Accepted
time: 37ms
memory: 117348kb

input:

erwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwaterwat...

output:

12
12
20
45
12671
16531
6
15
35
4
30
16
8
6
7
12
28
8
19683
18351
5
25
11018
3
10
6
20
35
20000
15
5
15
3
20
14967
8
5
8
10
10

result:

ok 40 lines

Test #32:

score: 0
Accepted
time: 43ms
memory: 129696kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2499999999
2499999999
2499999999
2499999999

result:

ok 4 lines

Extra Test:

score: 0
Extra Test Passed