QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#866030#1219. 你的名字kirihara233100 ✓2776ms263028kbC++144.6kb2025-01-22 10:55:452025-01-22 10:55:54

Judging History

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

  • [2025-01-22 10:55:54]
  • 评测
  • 测评结果:100
  • 用时:2776ms
  • 内存:263028kb
  • [2025-01-22 10:55:45]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int N = 1e6 + 29;

string s, t[N];

int ql[N], qr[N], m, n, ptr[N], cnt = 1, lst = 1;

struct node
{
	int c[29], len, fail;
	int& operator[] (const int& x)
	{
		return c[x];
	}
}tr[N];

namespace sgt
{
	struct node
	{
		int l, r, x;	
	}tr[N << 2];
	#define ls (p << 1)
	#define rs ((p << 1) | 1)
	void bd(int l, int r, int p = 1)
	{
		tr[p] = {l, r, 0};
		int mid = (l + r) >> 1;
		if (l ^ r)
			bd(l, mid, ls), bd(mid + 1, r, rs);
	}
	void up(int sx, int x, int p = 1)
	{
		int l = tr[p].l, r = tr[p].r, mid = (l + r) >> 1;
		tr[p].x = max(tr[p].x, x);
		if (l == r)
			return;
		up(sx, x, (sx <= mid) ? ls : rs);
	}
	int ask(int sl, int sr, int p = 1)
	{
		int l = tr[p].l, r = tr[p].r, mid = (l + r) >> 1, res = 0;
		if (l >= sl && r <= sr)
			return tr[p].x;
		if (sl <= mid)
			res = ask(sl, sr, ls);
		if (sr > mid)
			res = max(res, ask(sl, sr, rs));
		return res;
	}
	#undef ls
	#undef rs
}

namespace Tree
{
	vector < int > E[N];
	int dfn[N], en[N], idx;
	void dfs(int u)
	{
		dfn[u] = ++ idx;
		for (int v : E[u])
			dfs(v);
		en[u] = idx;
	}
	void init()
	{
		for (int i = 2;i <= cnt;++ i)
			E[tr[i].fail].push_back(i);
		dfs(1), sgt::bd(1, idx);
	}
	void up_p(int p, int x)
	{
		sgt::up(dfn[p], x);
	}
	int ask_p(int p)
	{
		return sgt::ask(dfn[p], en[p]);
	}
}

using Tree::up_p;
using Tree::ask_p;

void ins(int c)
{
	int cur = ++ cnt, p = lst;
	tr[cur].len = tr[p].len + 1;
	while (p && !tr[p][c])
		tr[p][c] = cur, p = tr[p].fail;
	int q = tr[p][c];
	if (!p)
		tr[cur].fail = 1;
	else if (tr[q].len == tr[p].len + 1)
		tr[cur].fail = q;
	else
	{
		int x = ++ cnt;
		tr[x] = tr[q], tr[x].len = tr[p].len + 1;
		while (p && tr[p][c] == q)
			tr[p][c] = x, p = tr[p].fail;
		tr[cur].fail = tr[q].fail = x;
	}
	lst = cur;
}

LL ans[N];

vector < int > Q[N];

int lp[N], bel[N], vis[N];

namespace SA
{
	string s;
	int sa[N], rk[N], rk1[N], ht[N], cnt[N], a[N];
	void srt(int w)
	{
		for (int i = 0;i <= n;++ i)
			cnt[i] = 0;
		for (int i = 1;i <= n;++ i)
			++ cnt[rk[sa[i] + w] + 1];
		for (int i = 1;i <= n;++ i)
			cnt[i] += cnt[i - 1];
		for (int i = 1;i <= n;++ i)
			a[++ cnt[rk[sa[i] + w]]] = sa[i];
		for (int i = 1;i <= n;++ i)
			sa[i] = a[i];
	}
	void init(const string& t)
	{
		s = t;
		for (int i = 1;i <= n;++ i)
			++ cnt[rk[i] = s[i] - 'a' + 1];
		for (int i = 1;i <= 30;++ i)
			cnt[i] += cnt[i - 1];
		for (int i = 1;i <= n;++ i)
			sa[++ cnt[rk[i] - 1]] = i;
		for (int i = 1;i <= n;++ i)
			rk1[i] = rk[i];
		for (int i = 1, j = 1;i <= n;++ i)
			rk[sa[i]] = (i == n || (rk1[sa[i]] == rk1[sa[i + 1]])) ? j : j ++ ;
		for (int w = 1;w < n;w <<= 1)
		{
			srt(w), srt(0);
			for (int i = 1;i <= n;++ i)
				rk1[i] = rk[i];
			for (int i = 1, j = 1;i <= n;++ i)
				rk[sa[i]] = (i == n || (rk1[sa[i]] == rk1[sa[i + 1]] && rk1[sa[i] + w] == rk1[sa[i + 1] + w])) ? j : j ++;
		}
		for (int i = 1, j = 0;i <= n;++ i)
		{
			if (j)
				-- j;
			while (s[i + j] == s[sa[rk[i] - 1] + j])
				++ j;
			ht[rk[i]] = j;
		}
	}
	void clear()
	{
		for (int i = 0;i <= max(n, 30) + 10;++ i)
			rk1[i] = rk[i] = ht[i] = a[i] = cnt[i] = sa[i] = 0;
	}
}

void work(int id)
{
	int l = ql[id];
	n = (int)t[id].size() - 1;
	vector < int > st;
	for (int i = 1, u = 1, len = 0, c;i <= n;++ i)
	{
		lp[i] = 0;
		c = t[id][i] - 'a' + 1;
		while (u && !tr[u][c])
			len = tr[u = tr[u].fail].len;
		if (!u)
			u = 1, len = 0;
		else
			++ len, u = tr[u][c];
		int p = u;
		vector < int > st1;
		while (p && ask_p(p) - tr[tr[p].fail].len < l)
		{
			if (vis[p])
			{
				p = bel[p];
				break;
			}
			st1.push_back(p);
			p = tr[p].fail;
		}
		for (int x : st1)
			vis[x] = 1, bel[x] = p, st.push_back(x);
		int tt = (p == u) ? len : tr[p].len;
		lp[i] = max(0, min(tt, ask_p(p) - l + 1));
	}
	reverse(lp + 1, lp + 1 + n);
	reverse(t[id].begin() + 1, t[id].end());
	LL res = 0;
	SA::init(t[id]);
	for (int i = 1;i <= n;++ i)
		res += max(0, n - i + 1 - max(SA::ht[SA::rk[i]], lp[i]));
	ans[id] = res;
	for (int x : st)
		bel[x] = vis[x] = 0;
	SA::clear();
}

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s >> m, s = "$" + s;
	for (int i = 1;i <= m;++ i)
		cin >> t[i] >> ql[i] >> qr[i], t[i] = "$" + t[i], Q[qr[i]].push_back(i);
	for (int r = 1;r < (int)s.size();++ r)
		ins(s[r] - 'a' + 1), ptr[r] = lst;
	Tree::init();
	for (int r = 1;r < (int)s.size();++ r)
	{
		up_p(ptr[r], r);
		for (int id : Q[r])
			work(id);
	}
	for (int i = 1;i <= m;++ i)
		cout << ans[i] << "\n";
	cout.flush();
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 4
Accepted
time: 17ms
memory: 108020kb

input:

aadccabccdcddcdabbbdbdaabcadbcadcccdcadbadaabaaacbacdcdccdcdabbbdbdaadcabdabdbacabdadadbdadbdcddbcbcbaddaaaabccdaddcaaabdbabbcabdbcdccaaddbdcdbbcaccdababdbbdabdcbcccacbddddaacbaccaacadbdbdcabc
190
acdabdbcdcabbacbdacaccbcaddadabccdaabdcdcbcdaadccadcdcaccdcaadcaaddccddbbbadbadbdcaacccdbbbcbdbabcacacb...

output:

18746
19133
18512
18928
17590
17762
17395
18333
17397
18159
18708
19076
18526
18931
17953
18684
17555
17937
17602
18932
17972
17768
17746
18939
18728
18167
17957
18718
18486
18170
17597
18174
17368
17591
17579
18364
18741
19150
17426
18514
17961
17398
18123
18742
17775
17402
19132
18151
18738
17418
...

result:

ok 190 lines

Test #2:

score: 4
Accepted
time: 17ms
memory: 111392kb

input:

adbdadddcaddcdaacabadbbbacccaadddcdabaaccbbcbacccbdcdbaabbcbddcdadcabcacccccddbdabbbaacaadcdaddbabcabbbddcdccbaddbbbcdbcabdaaabbdaaadcdacbabccdadbabbdaddcbccddadbdcabcdaabbbabcdacbcaaccabcbaabcbcddcddbbbbaadacbddabbdddabbddbcbdabccbbdacbbdccdbddcdcdcadadbbacbdabbbcddcbadcdddaaabdbbdadddaabbdbaaccdab...

output:

17803
18533
18159
17409
17751
18527
17214
18141
18343
17601
18158
17623
18721
18552
18945
17413
17228
17577
18527
18694
17413
17564
17999
18521
18545
17400
18354
17384
18378
18159
17415
18907
17410
17594
17365
18126
17764
18370
17220
18352
18338
17616
17400
17244
18945
18201
17957
17774
18918
17970
...

result:

ok 191 lines

Test #3:

score: 4
Accepted
time: 17ms
memory: 113000kb

input:

abbabcabadbcbbccbabdcbbacdddcccddadabcadabaadcaddbaaccacaabcbbbcabbbdcbadbaadccdbbdbaaccadbbabdccbcaabbaaccabcbabbcaacbdbbadadbdcbddbbcddcaaacbadabbaacaadddacbadbbddaabbcaccdbdabbcdbbccadccaadabccdaddcabbabadadabdbbadacadcaacbcdccdccaddaacdccbacadaccdbccddacbdcabadbcbbaaccbbabcddccdaabacbcbdbcbdbddb...

output:

18912
18173
17219
18910
18551
18349
17395
17373
17739
17934
17975
17576
17237
18552
18712
18941
17913
17203
17385
18945
18568
17180
18135
17208
17989
17984
18347
17798
17974
18909
18159
18724
18558
18540
18761
17987
18512
18388
18171
18352
17435
18936
18151
17765
17772
17225
18750
18553
18166
17965
...

result:

ok 198 lines

Test #4:

score: 4
Accepted
time: 129ms
memory: 108472kb

input:

ddadbccdbdaacdacabdadadcbdbbadddcadbdadddcaddbbacbddddacccccbcabbbdaddcacbbcaaadaaddadadddbadabbadcdbacbdaddadbbbbccdbacaaabcacccdccaaabaddababacdbaccbbbddaabaacadbcddbbcaaccbbbbbdaddaabddbcdbaacbcadbdbccbcbbdacdacbbbcdccadcdbaacbcaadbabadcaccabdddacacabdbcdadccaddcdcaaabcacccbdbdadcbdcabddabbdabdcd...

output:

2894585
2991616
2979335
3050618
2815847
3097694
2950143
2865797
2830060
2947789
2811062
3067958
3030865
2892211
2861038
2977006
3070490
3023569
3023484
2913801
2913793
2825275
2825292
2923566
2880180
2991687
3028451
3072797
2925914
2957369
2837214
3026044
3035938
3033378
2996555
2994152
3043224
2964...

result:

ok 197 lines

Test #5:

score: 4
Accepted
time: 117ms
memory: 113200kb

input:

bacccaaabdacddbbabdabccbdabddccdbcdcdbdbccbddbbcaaddaacdcaaadcbcaddbabbaddaaaddaaccdcaccacababccaddaccbcacbbdccabaacacdcbccbdbadcdbbbbacacdcbbbbaadbcbaadbcadadbbddbccaadbdbcbabdaacdcdacdbcdbdccdabbacbddabcabccbbabcddbdddcaabbcaddbbdabcaddbbcaadabcbdcabcacdaabbdddadaacbbccdbccdabbdcaddddcccdaaaaddada...

output:

2969627
2930836
3090327
2969685
2940547
2959956
2913833
2822831
3001405
2938139
3023485
2998971
2952629
3075473
2844312
2858668
2911472
3053170
2984323
2950225
2984348
2832415
2868277
2962343
3003817
3006315
2889901
3045670
3097695
3038344
2822860
3090336
2933267
3028519
2933159
3060548
2889805
2996...

result:

ok 191 lines

Test #6:

score: 4
Accepted
time: 687ms
memory: 263028kb

input:

jmoifvagmonbuxznpdxtcgfycygerridhihasxonifvcorwbbadpyjvgyveicsfcrcjjecfktxuumtvfjxocbgeoeefrzlykfqeaarrlhkjovevehnezlcjikjjjfuxfoclvirrbctlicoitgwnphfzgzepxyejlsijruxxdvzahqjpaqhgcumtjnwkbskyengdgzbtxteacjoyvndwiturrdtlcyccbckhmlfyqohfcjvzhtcuqxxpexkvlckohvidmwkghiijakocqyjskcfoxxzffzgtylbiyythobvdx...

output:

124863337763

result:

ok single line: '124863337763'

Test #7:

score: 4
Accepted
time: 714ms
memory: 262588kb

input:

jxfsgnlqidcnbfleihizzderbbyzminbutjjknmojrymnghyunksfsqtfijisxyxfaygactkupfrpnugcrvhseqxpdiyrzrzanctqtygvhpumvlxwmvduwbysmkzpckcgbjxmlgyfhdpdjqehloisnpilhpshexuljbjlnkcbkjcnpudmycjigdirokeyvcvkmkrsyjbftizewmcfyuxghxqmwmqdvhswdnsjvybvefdnupdkrqcvnlnfbybifdovvapsdjoppvzvkmxjzevqifzclignjponvndafghncmm...

output:

124869633540

result:

ok single line: '124869633540'

Test #8:

score: 4
Accepted
time: 113ms
memory: 147992kb

input:

lbmckmhibhhmgglmcbfkclhacldibgaadakchjabmimjlidhhldljfmkegaieahdbjccdhjefbfebedjiefeflbejkihgjbfgeflchegbamekdlaaacfgabdabmfgjgfmjailbdgbhfbmaaclcidkkgldmejjhcmahhmgkimgfclcgkkalgdcmaiieakmkmflhbdmmibkbkfcjieekbccheahgegkfchfchemgkfghmiabllamichbbdbhjlcfafkijgihgmekhkdebkfbkdagdbhcgjmkamlfhmkjgmfafl...

output:

199927488
12
4
10
8
12
7
10
11
8
7
12
9
12
11
6
10
10
6
11
5
11
8
9
8
11
9
5
11
11
10
2
4
10
13
9
11
8
8
10
10
11
10
12
11
10
7
10
9
6
10
9
12
10
9
11
12
11
11
11
10
7
8
12
10
12
9
7
5
10
12
8
8
8
10
7
12
7
11
12
9
10
7
10
12
10
13
9
8
9
8
8
9
9
11
11
8
6
4
0
6
4
8
10
9
13
9
12
13
7
7
10
11
8
7
10
8...

result:

ok 4411 lines

Test #9:

score: 4
Accepted
time: 125ms
memory: 135120kb

input:

uwhchfeaycdqlasqdrbylqxaridtgcmyrmkdfdahthdwvkojhqxacqomockaqqoanitzhkmcgcdvniteghvxiyjrqziqjiuljewrdwaabtqwfrfalgloikpxcllbngrzphwcsdmiflqvznvuvxivxsvpqfgkefowexaoplhqfenuwawvwhtmocrmqifqdbyudhmkgiucudnxbjaucppbzobxpmqufhvexdvyjiefmxlfpczvqiuqucvnryxicvusurdiaavudphnnmfqgtichpwfvpaglqqzlmbwwwjohdgx...

output:

199945526
2
3
2
3
3
1
3
3
3
2
3
3
3
3
3
3
3
3
3
2
3
3
3
3
3
2
3
2
2
3
2
3
2
2
2
3
2
3
2
2
2
3
2
1
3
3
3
1
3
3
2
3
2
3
2
3
2
2
3
2
3
3
2
1
3
2
3
3
2
3
3
1
3
3
3
3
2
2
3
2
3
0
3
2
3
2
3
3
3
3
3
2
3
0
3
3
3
2
3
2
3
3
3
3
2
3
3
3
2
3
3
3
3
3
3
3
2
3
2
1
3
3
3
2
2
3
2
3
3
3
3
3
3
3
2
3
2
3
2
3
2
2
2
4
2
...

result:

ok 5706 lines

Test #10:

score: 4
Accepted
time: 234ms
memory: 162676kb

input:

kimblfhedhamehaaacifgbgflkkldkalaakkhlaiejmeccmcffablhblmggjdmkbhljkkhgfjklieakmkjaamgikmccfkfghljahlkijgjdaechcbifailjcglkkedlgicjebfhiebkfciljkeacceejmkaalhcajfhfmkcecdklbdajdlfikkhiekdbebjbbdfgjcjhfbkclbhbbhjfdffegebkjfkcdilemclilbhflaihgihcgkldcbaakhdjhbekibbigibjdmjbbfalhccmddmckgljfmhgjbalbdjg...

output:

799877758
11
1
11
13
12
10
10
8
10
7
13
8
9
12
11
11
1
14
10
7
2
8
8
8
11
4
9
10
9
11
10
4
8
6
2
11
12
10
7
8
10
12
10
7
0
10
11
4
7
6
8
1
4
5
10
10
6
9
11
11
9
4
11
11
11
12
12
8
11
12
12
8
11
12
8
9
6
12
7
8
8
9
8
9
11
10
7
13
9
11
12
10
11
11
11
9
8
9
2
13
8
12
9
8
8
3
10
12
12
11
10
8
11
9
10
11...

result:

ok 8521 lines

Test #11:

score: 4
Accepted
time: 255ms
memory: 155472kb

input:

hpfxngoxndlosbzylksgzehfhkodfvqwwbtwlreetgeusomoymlaukhqqeqhfawfvuqjbwyrtwwjzmrtrnhvibtibiachlutcqbsydmynzxzdrkydyyekbmezwhvvfngnlklzdjpgbpjatahwuvoluqjoefktvlwdtynwprfekbpvgqtwmwneaofpktxfudwpibhlqmiybqbvsfsywlbktjcqvzwxtddkmliwukvkqsdssszsbmtnpynoohpgclvufblcdvqwrpjtuayinwqppbuidyynbpaolisqodbrqqt...

output:

799884036
3
2
2
1
3
2
3
2
1
3
3
2
2
2
3
2
3
1
3
2
2
2
3
2
2
1
3
3
3
2
3
0
3
1
2
3
2
2
2
1
3
2
0
3
3
2
2
3
2
1
3
3
1
2
3
2
2
2
2
2
2
3
3
3
3
2
2
2
2
2
3
3
3
1
2
2
3
2
3
1
3
2
3
3
2
2
2
2
2
2
0
2
2
2
3
2
2
2
2
3
2
3
3
2
3
3
3
2
2
2
2
1
3
3
3
3
3
2
2
2
3
2
2
3
2
3
2
2
2
3
3
3
2
3
3
2
2
1
3
3
2
3
0
3
3
...

result:

ok 11413 lines

Test #12:

score: 4
Accepted
time: 384ms
memory: 186636kb

input:

cdfmjmimggmlmabjlakafafdgkbdkaclfemhajdamjkliajhmajfidkghmejelfkjedddkcgbdidelhghbabckiihdjhdjhakmeldjbikdagdfhalfikeggefcmehhgccilmaehhkagafafaegjgakjekcbhbbjgfhimhmlblgmeddfffdhfgmiacadfhglhjaekdaeacdbfmlcjfffbkcbffljjkbhigejmmmhkaljcljibgekjfhefmbjilcahefblblgeledddgemdgihfecclicgbkmilmifflllhmmc...

output:

1799824843
7
13
11
8
5
12
12
7
12
8
7
10
10
7
7
5
10
0
1
8
5
4
8
1
7
11
7
8
9
11
11
9
8
5
10
10
12
11
10
12
10
7
0
12
11
12
10
10
6
11
5
12
10
10
7
5
10
10
11
10
12
7
7
8
11
8
13
10
10
11
6
10
11
13
13
7
13
8
12
4
11
6
7
11
10
13
5
7
8
2
6
8
6
8
14
11
5
3
8
12
8
9
12
7
9
11
9
9
11
9
8
9
7
4
7
11
11
...

result:

ok 12631 lines

Test #13:

score: 4
Accepted
time: 435ms
memory: 181732kb

input:

ophmmxojwyabxitozutwdxkmleazyhkqzfhqtdjggpjclzkhcerzmpdkprqjkmnpvccyajlwcohqgzqticihosjhxmwymdzoqnawgmtegjqyrngnqcheacmkgbrwsfldsmlnqjkocblhrnwguaexvnfvrceexfqpzumxsuuhfhdhujqoqdxrkknnhiygrabiqspaqdqreiswbcqdjnyqijdzolltfiiismxltjukwuixllitlyjglwwqekrlbkbwutvnifampunpzmpmwyclwxwgrowvnbqqmkreqhrwgvey...

output:

1799817649
2
1
0
1
2
3
2
2
3
1
1
2
3
1
1
3
2
2
3
3
3
1
2
3
2
2
3
1
1
3
2
1
2
3
2
2
3
2
3
2
2
2
1
3
3
1
2
3
3
2
1
2
2
2
2
3
2
1
1
2
3
2
0
1
2
2
2
2
2
3
2
3
1
3
3
3
3
2
3
2
2
2
2
2
3
2
3
2
3
2
2
2
2
2
3
3
1
2
2
3
2
1
3
3
2
3
2
2
1
1
3
3
2
2
2
2
1
2
3
2
1
2
1
3
2
2
2
3
2
2
3
2
1
2
2
3
2
1
3
3
3
2
1
1
3...

result:

ok 17118 lines

Test #14:

score: 4
Accepted
time: 607ms
memory: 221300kb

input:

lbmafbiicbjcmhbbmbabkgmbafmmhjldiifkmhejgmdcbijilcaidajjjebklkikjdjefalfkemjmbifalacllkcehbgkdkabiiefmhjcimlmckcbebidhddclhhlabdalegkfhcdbejbdmbhbfgelmkfdbkbdaclahbfggijmbgigilebmbijddfkjbafdjghijiibljgclgbciijhmjdhcjelmhiecaiahkhledfbekdlmcdceecckhkebclhilgbikmfgjmjgflmffkdjjkbcaemagedmcjajgikgefga...

output:

3199770934
9
9
11
8
9
10
10
13
9
10
8
11
11
10
11
8
10
10
11
8
10
4
4
11
11
9
11
8
11
11
4
12
7
12
11
11
12
8
11
8
6
1
10
10
7
6
11
10
6
11
10
12
8
7
4
11
5
7
11
10
4
10
3
6
12
13
10
8
9
8
12
5
12
10
4
10
10
8
10
8
10
6
14
10
0
10
10
10
12
5
8
1
10
9
11
12
9
5
10
6
9
8
6
9
12
10
12
10
8
11
11
12
5
1...

result:

ok 16741 lines

Test #15:

score: 4
Accepted
time: 634ms
memory: 201176kb

input:

dsppfaesydhozppylwmfzcvsllhggovukeeepvtiodzzdcmlauhymvxijszrobdecuhxjsivtwjtmvphssgvyifmixgddeuofabohugyfnnqbtsjrynkvtvcqkrhwovooktcfwmxagrxgekxdgldaqffybwmdkeykyocudevwdojhcbhipfwclhzmtoyznnbdadomffoaxihkuojezabjppeyzkgwjgcpvuuxvojahfrdeybcklvqwvfftcwkxqfhbddbxfduvitycznkuzgukryyhktzoslzqiiggugpwvr...

output:

3199747543
2
1
2
1
3
3
0
2
1
2
1
2
0
2
2
1
2
2
0
1
0
2
1
2
1
2
3
2
2
2
1
2
2
2
1
3
1
2
1
2
2
2
2
2
1
1
1
3
1
1
3
1
2
3
2
1
2
2
2
1
2
1
1
1
2
2
2
2
1
2
2
2
2
2
3
2
2
2
2
3
2
1
1
2
2
3
3
2
2
1
2
1
3
2
1
2
3
1
3
1
3
2
2
3
2
1
2
2
3
2
2
2
2
3
3
1
1
3
0
1
1
2
1
1
1
2
1
2
2
0
1
1
3
2
2
3
2
2
2
3
3
1
2
2
2...

result:

ok 22825 lines

Test #16:

score: 4
Accepted
time: 711ms
memory: 238224kb

input:

lgcjmilcjkfljihhadhcgcljecggdihjjihgdmbgggmdmfligahflfffcbcmfjlfmamfmcllfgffcciihhcfdihlbgbklmkjacjkhjajhaijifebillabigdeichhklajlechjhbeaiahhidemiaaaehkkaelabbdchficchchdcljbbbdmjfldkmjledjkkhldjjagdimadbdkkmcblkgfbmghieiiaamicjlemabecdemjbbhjjadfhlbaaglbfbbbilljmfjmadcmckfegfalkacbkjkafcgaklgabjkm...

output:

4999715467
11
11
11
8
9
0
10
0
10
12
10
11
11
8
11
11
12
9
9
10
5
11
9
9
8
12
12
11
9
10
12
10
8
12
7
7
11
4
11
0
8
10
6
12
5
8
8
12
3
4
7
11
10
8
8
10
10
5
11
10
9
10
12
8
1
12
9
11
11
13
10
6
8
4
9
10
11
11
12
7
4
10
12
4
0
10
8
6
12
11
10
8
10
11
10
9
11
8
5
13
11
10
8
11
10
12
11
12
9
7
10
8
6
1...

result:

ok 20852 lines

Test #17:

score: 4
Accepted
time: 847ms
memory: 238452kb

input:

crouxgkvirnjrytirundlljrgfwtazivrwzxxwditbfcooymmlaqvtisxnwbhhdusjrqtvebvgmuaietaotldzzsrqtplqfucfyjpfrohwraeeufvpetorvakablkyvvnwetsrqjlxhmjwgqekapdrvcymvxdzojvbsvcjqrjsdnimathoxcldskndebsfnoqpwxjiicaqdaxhmfnozvwhezimqwnwaoktflkfpdqyhuwtdtgqanymowveuxayebwbjeliulrglhaxwgmgvgiqwqvrkwetmdvkshxwpobakc...

output:

4999675655
3
1
1
2
1
2
1
2
3
2
2
1
2
2
1
3
1
2
1
1
1
2
2
2
2
1
3
2
2
2
0
1
1
1
2
1
3
2
3
2
2
3
1
1
2
3
1
2
2
2
1
2
1
2
1
2
2
2
2
3
2
1
2
1
1
1
1
2
2
3
1
1
2
1
2
2
1
2
2
2
1
3
1
1
1
1
2
1
1
2
2
1
2
2
1
1
2
2
2
2
2
2
1
2
0
2
2
0
2
2
1
1
2
2
3
2
3
2
2
1
2
1
3
2
1
1
1
2
3
2
2
2
3
1
1
2
2
2
2
2
1
1
2
3
1...

result:

ok 28531 lines

Test #18:

score: 4
Accepted
time: 2105ms
memory: 168232kb

input:

hlheiljjdhhlgihkakdbmjjkjbihblhabaaafedcjickgbmimhldcfdgaeaemhheclgeglffkkiklgalagllffkjkkjbkllkgkkbblficjmklljcfallcicmfdflgebfjeacjejeedmimfdeiadbegfkckiaffagigmckdkihdikgilgehmaglhiddljghmfhgikfkgmfkadekgfalhlemfkdeggcdfkhmjdcdabmeebblbgeflbhkcjgdgadlbfmdebkhhhfajjiflejijamgjekelmjhcmakcglmhafdai...

output:

4999734984
8
12
5
11
9
12
13
9
11
10
5
13
8
13
9
8
11
5
6
9
13
8
9
8
8
3
12
5
13
11
13
9
13
14
11
11
11
5
12
12
8
5
9
14
10
12
14
8
9
11
5
12
5
13
8
12
13
13
11
10
11
12
10
12
13
1
9
14
8
9
5
12
5
0
14
14
12
8
8
11
12
11
11
12
7
9
10
7
10
14
13
5
9
8
7
11
12
9
11
14
11
9
8
12
9
11
1
11
7
12
9
11
11
...

result:

ok 20852 lines

Test #19:

score: 4
Accepted
time: 2324ms
memory: 194880kb

input:

hcickbjbggigfjddcmijgfbafdebdkcldbibaaegkhmdeibkjdjigbmfelkbdablaccmeblcgikdglmllmdagaaaikfjhdcldhmhmiiiccbhehdhbkjdgkkjhfkflckidfibicfihaagficicjkbiiejddegmcahacchfgmkmmlehbelhlmbkamelfjhkmgfljbaffjjfmfhmhafjhhhdlgfggbilkkcghfaalllcdeffbbjichaiedagaalehkcaglcacgldciahdgehibefmghedciddglfbbmdigdbjij...

output:

4999739719
13
5
11
8
10
13
9
9
8
12
9
11
7
5
13
11
5
6
6
10
12
3
10
1
13
6
12
11
11
6
0
12
8
8
3
10
12
14
13
11
10
12
13
11
9
13
8
5
12
5
12
12
8
9
10
0
14
11
11
9
5
14
10
9
10
4
6
14
8
10
9
9
8
7
12
8
9
8
11
8
11
13
13
5
6
11
14
12
5
5
15
11
0
11
6
11
11
12
11
12
13
8
1
9
9
13
9
9
0
12
13
12
13
13
...

result:

ok 20852 lines

Test #20:

score: 4
Accepted
time: 2530ms
memory: 227720kb

input:

cjhkkbhdfmbagemlcmcdclghhcebjlaikgbdlbkedeckmimkeffkjfljmghahfgeihehlfhicjckhjmidafdkhfgehjdgdclckchjddkglaijcfcmigkgmhkmggelagbkbkikaghbadbfeifkemehhcljcfjeljejeehbklflekflaedfeclhidaahikdfaeljbhbaffkdblmecidjglkddkmecifgccmjkjhjecgaklmemfcfemlfmbkljjbakdhchehfhaelhgkicdbhgddcfjeikimklccbdmccjiilhf...

output:

4999718204
13
12
13
11
15
9
12
11
10
9
1
7
12
12
9
13
11
13
5
11
5
12
12
10
11
14
8
11
12
11
13
11
12
11
11
11
9
14
13
11
12
13
11
12
12
11
14
12
13
5
10
11
7
8
13
13
14
14
0
5
11
9
9
5
14
12
9
1
5
0
8
13
11
13
13
8
5
8
1
10
12
9
7
5
11
13
12
13
11
12
5
0
13
12
4
14
11
11
13
11
11
6
11
10
8
13
11
14...

result:

ok 20852 lines

Test #21:

score: 4
Accepted
time: 2744ms
memory: 248404kb

input:

acdalbjachemiccjijekjladlmgcdibegjemfggmcajmkdfaicklclhhjjiifdjkglcdieahidalajicmabkejeggmjdacmljghlicficlaidacjegkhgdmalfbgakblgfbglebhjmkccfgkdkcbgddfgcmkkddlmlikljhmcgfddgkfhddkiekkaefbedjhglclfgebfddlbkkadhlahccmbgjagkkchemmhgbcjkcjdgbmbfhmhgckffedkkllkemkegjhbkijhkjmckkgcccebelfdikbfeigdflebkck...

output:

4999757046
9
13
9
8
11
12
12
6
14
11
5
12
10
10
11
12
11
11
12
8
13
7
5
5
11
9
12
13
13
9
10
11
10
10
4
11
11
11
14
13
11
9
12
8
8
14
10
9
5
10
14
13
1
8
11
5
9
11
10
3
12
10
12
9
13
0
11
11
8
11
8
13
13
9
4
10
14
9
11
10
10
11
10
0
10
2
12
4
9
11
12
12
11
13
12
14
5
7
10
8
12
8
13
14
10
14
13
13
11...

result:

ok 20852 lines

Test #22:

score: 4
Accepted
time: 2624ms
memory: 244492kb

input:

mddlmgjdadiajebkkjdcfcaemmacbeefbiheblhihlahcilkgcgcgbgbkdddbiedlejkaibalfggglkghmddiiikfabgmggecdmifaegcmkfcmlcfhlecifdiejflclehcbajacmakchcekkiddljfdlejgefbgkgicbdjamafjfgcdmhaejffmdaedaidabihdckhjdkfdclaafcibjfidakllflmejfaeeilaehkicmifjcdiagiihchgefafeaabbihmkddcaembjgjdeljjldagjgghammkfagahdjgb...

output:

4999718831
10
11
0
15
11
14
12
11
14
5
13
12
9
9
6
13
13
13
12
9
14
13
14
10
12
9
5
11
9
13
11
11
12
6
11
12
14
9
0
8
12
14
14
9
12
9
12
5
12
14
11
12
11
12
11
9
14
10
11
12
11
13
11
12
8
5
13
12
10
12
5
12
8
7
15
9
12
9
14
0
13
12
1
5
9
15
9
12
11
11
11
9
13
9
11
11
11
9
8
8
8
12
5
0
7
13
11
9
9
11...

result:

ok 20852 lines

Test #23:

score: 4
Accepted
time: 2604ms
memory: 246468kb

input:

llfdgmcekbmbimkccddilecgmlimhkklijdgcfjcdkblbglbaaegedfeihjfgigigfbajgakjmmafechejfihfmdkidmlfdcejkkielgcakckilmlgiklmlalklfdcgkhlmlhkjbkhmdkbhmbfidfmccicgcbejmklcmelcigfjjiaifebbdimekgaglhejaadaglhahfkmkljkfakaifihfihikecehmafbgicelabajgghlmffhgfciclmhmbfhbkbbffmikkeadafebkjkdcidbgadmiaelbhkegimmbf...

output:

4999718003
11
10
12
12
11
10
8
11
12
12
13
9
0
12
14
9
4
12
14
11
11
14
11
9
11
11
14
9
11
12
14
11
11
9
12
15
12
8
14
13
13
9
12
7
5
13
13
13
10
13
10
11
14
9
12
13
9
12
8
11
9
11
15
11
9
11
8
11
12
2
11
13
1
11
11
11
8
7
12
13
9
9
13
9
14
5
12
12
12
6
5
6
9
12
13
12
11
13
14
12
13
14
9
12
0
11
12
...

result:

ok 20852 lines

Test #24:

score: 4
Accepted
time: 2721ms
memory: 246068kb

input:

dhblhcfekgfmbjkhalldhjckleeffihfallgiafelkkehflcmbikdiijmajkeaghlddammajjdffieiidbgedfekciajfflgbgegmfmaljamaliihmjladahiglmkafmiiflcbhbhceimhmhheeidaejgaecmahcmchclijjdjajmkjgjdgkhmljmjlgadflbdkdkgbggdddicllcfkdmajigmglkfcllijleblcaabkajjghhdgkdbllmjhahjecccfhcgmfemljbkamhgbehjkfffaickeagejjhkgmimb...

output:

4999724403
11
11
9
0
8
7
10
12
11
11
12
11
11
12
12
11
5
5
11
11
14
9
9
10
12
9
11
10
9
11
11
12
9
11
13
6
13
12
11
10
13
9
9
12
1
9
14
12
1
13
9
9
9
13
11
13
14
12
11
10
11
8
0
12
7
13
14
11
13
9
10
10
10
9
14
5
8
9
3
5
5
11
5
13
12
9
5
13
11
12
8
11
14
9
14
12
9
9
11
0
11
8
11
12
12
14
6
11
11
13
...

result:

ok 20852 lines

Test #25:

score: 4
Accepted
time: 2776ms
memory: 246428kb

input:

iiafeelfecahcjmkadhjkdmmelhmaiafglhiabmlafgmackbbkgfdhdhlageljhmlmehhjgbgkjmbaiffjhcfceiidghmggkhlhkcjdjiehfdcjdlkblgbkcdahgiccjiimggkdlhlkgddbiigbjhbdblbggaealbkldjbfdecmcijdfajlgccfbldbkjmbcmkklfmjfblbhieibecfgjcbchkegbdamflhfjfdgjglkakkgheakegkhlllmhljekmidlhfcmjlgmmajmgjmmlfkhhbklgliejcikjehdijd...

output:

4999717091
12
13
10
8
12
13
10
5
11
9
8
10
13
11
13
13
5
12
6
8
13
11
5
5
11
13
10
9
11
13
10
9
9
12
2
11
12
11
10
11
13
13
13
10
13
11
8
11
11
9
10
5
11
10
8
0
7
11
3
11
11
12
11
7
10
9
12
11
12
11
1
8
5
10
11
11
8
11
11
10
8
13
9
12
5
11
12
10
10
0
13
10
12
15
11
9
10
4
0
11
10
13
5
9
11
12
7
13
1...

result:

ok 20852 lines

Extra Test:

score: 0
Extra Test Passed