QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319087#1455. String Algorithmcxm1024AC ✓5730ms188488kbC++144.5kb2024-02-01 19:38:032024-02-01 19:38:04

Judging History

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

  • [2024-02-01 19:38:04]
  • 评测
  • 测评结果:AC
  • 用时:5730ms
  • 内存:188488kb
  • [2024-02-01 19:38:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int B = 360;
mt19937 rnd(114514);
int ksm(int a, int b, int mod, int res = 1) {
	for (; b; a = a * a % mod, b >>= 1)
		if (b & 1) res = res * a % mod;
	return res;
}
const int mod[2] = {998244353, (int)1e9 + 9}, base = 19491001;
int seed[26];
string s;
int n, pre[200010][2], pw[200010][2], invpw[200010][2];
const int MAXN = 400010;
struct SAM {
	struct node {
		int nxt[26], fa, len;
	} t[MAXN];
	int cnt, lst, sz[MAXN], ind[MAXN];
	int dfn[MAXN], dep[MAXN], tot;
	int lg[MAXN], tr[20][MAXN];
	SAM() : cnt(1), lst(1), tot(0) {}
	void insert(int x) {
		int cur = ++cnt, p = lst;
		t[cur].len = t[lst].len + 1;
		for (; p && t[p].nxt[x] == 0; p = t[p].fa)
			t[p].nxt[x] = cur;
		int q = t[p].nxt[x];
		if (q == 0) t[cur].fa = 1;
		else if (t[q].len == t[p].len + 1) t[cur].fa = q;
		else {
			int r = ++cnt;
			t[r] = t[q], t[r].len = t[p].len + 1;
			for (; p && t[p].nxt[x] == q; p = t[p].fa)
				t[p].nxt[x] = r;
			t[q].fa = t[cur].fa = r;
		}
		sz[cur] = 1, lst = cur;
	}
	vector<int> e[MAXN];
	void dfs(int now, int ndep) {
		tr[0][dfn[now] = ++tot] = now, dep[now] = ndep;
		for (int v : e[now])
			dfs(v, ndep + 1), sz[now] += sz[v];
	}
	void build(string s) {
		lg[1] = 0;
		for (int i = 2; i < MAXN; i++)
			lg[i] = lg[i / 2] + 1;
		for (int i = 0; i < s.size(); i++)
			insert(s[i] - 'a'), ind[i] = lst;
		for (int i = 2; i <= cnt; i++)
			e[t[i].fa].push_back(i);
		dfs(1, 0);
		for (int i = 1; i <= lg[MAXN - 1]; i++) {
			int x = 1 << i;
			for (int j = 1; j + x - 1 <= tot; j++) {
				if (dep[tr[i - 1][j]] < dep[tr[i - 1][j + x / 2]])
					tr[i][j] = tr[i - 1][j];
				else tr[i][j] = tr[i - 1][j + x / 2];
			}
		}
	}
	int LCA(int x, int y) {
		if (x == y) return x;
		x = dfn[x], y = dfn[y];
		if (x > y) swap(x, y);
		int len = lg[y - (x++)];
		if (dep[tr[len][x]] < dep[tr[len][y - (1 << len) + 1]])
			return t[tr[len][x]].fa;
		return t[tr[len][y - (1 << len) + 1]].fa;
	}
	int LCS(int x, int y) {
		return t[LCA(ind[x], ind[y])].len;
	}
	void clear() {
		do {
			memset(t[cnt].nxt, 0, sizeof(t[cnt].nxt));
			t[cnt].fa = t[cnt].len = 0;
		} while (--cnt);
		cnt = lst = 1, tot = 0;
	}
} T;
pair<int, int> geth(int l, int r) {
	return {(pre[r][0] - pre[l - 1][0] + mod[0]) * invpw[l - 1][0] % mod[0],
			(pre[r][1] - pre[l - 1][1] + mod[1]) * invpw[l - 1][1] % mod[1]};
}
unordered_map<int, int> mp;
void solve1(int k) {
	int ans = 0;
	vector<pair<int, int>> v(n / k + 1);
	for (int i = 1; i + k - 1 <= n; i += k)
		v[i / k] = geth(i, i + k - 1);
	for (int j = 0; j <= k; j++) {
		for (int i = 1; i + k - 1 <= n; i += k) {
			auto tmp = v[i / k];
			if (j) {
				(tmp.first += mod[0] - pw[j][0] * seed[s[i + j - 1] - 'a'] % mod[0]) %= mod[0];
				(tmp.second += mod[1] - pw[j][1] * seed[s[i + j - 1] - 'a'] % mod[1]) %= mod[1];
			}
			if (j == 0) ans -= mp[tmp.first * mod[1] + tmp.second] * (k - 1);
			else ans += mp[tmp.first * mod[1] + tmp.second];
			mp[tmp.first * mod[1] + tmp.second]++;
		}
		mp.clear();
	}
	cout << ans << " ";
}
int lcp(int x, int y) {
	return T.LCS(n - x, n - y);
}
bool check(pair<int, int> p, pair<int, int> q) {
	int tmp = lcp(p.first, q.first);
	if (tmp >= p.second - p.first) return 1;
	p.first += tmp + 1, q.first += tmp + 1;
	return geth(p.first, p.second) == geth(q.first, q.second);
}
void solve2(int k) {
	vector<pair<int, int>> v;
	for (int i = 1; i + k - 1 <= n; i += k)
		v.push_back({i, i + k - 1});
	int ans = 0;
	for (int i = 0; i < v.size(); i++)
		for (int j = i + 1; j < v.size(); j++)
			ans += check(v[i], v[j]);
	cout << ans << " ";
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> s;
	reverse(s.begin(), s.end());
	T.build(s);
	reverse(s.begin(), s.end());
	s = " " + s;
	for (int i = 0; i < 26; i++)
		seed[i] = rnd() % mod[0];
	pw[0][0] = pw[0][1] = 1;
	for (int i = 1; i <= n; i++) {
		pw[i][0] = pw[i - 1][0] * base % mod[0];
		pw[i][1] = pw[i - 1][1] * base % mod[1];
		pre[i][0] = (pre[i - 1][0] + pw[i][0] * seed[s[i] - 'a']) % mod[0];
		pre[i][1] = (pre[i - 1][1] + pw[i][1] * seed[s[i] - 'a']) % mod[1];
	}
	invpw[n][0] = ksm(pw[n][0], mod[0] - 2, mod[0]);
	invpw[n][1] = ksm(pw[n][1], mod[1] - 2, mod[1]);
	for (int i = n; i >= 1; i--) {
		invpw[i - 1][0] = invpw[i][0] * base % mod[0];
		invpw[i - 1][1] = invpw[i][1] * base % mod[1];
	}
	for (int i = 1; i <= n; i++) {
		if (i <= B) solve1(i);
		else solve2(i);
	}
	cout << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 16148kb

input:

7
kkekeee

output:

21 2 1 0 0 0 0 

result:

ok 7 numbers

Test #2:

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

input:

10
babaiskeke

output:

45 2 0 0 0 0 0 0 0 0 

result:

ok 10 numbers

Test #3:

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

input:

11
aaabaaabaaa

output:

55 10 2 1 0 0 0 0 0 0 0 

result:

ok 11 numbers

Test #4:

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

input:

50
vgjanpqrpxaqzckoaokxemqghpgeehegwjiqifenfpnttwbibs

output:

1225 21 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 50 numbers

Test #5:

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

input:

50
sngyxnmwrlyyhrplimxorsrvvllpykxxsuvoupoowyrwfvtwsl

output:

1225 32 1 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 50 numbers

Test #6:

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

input:

50
nzpywqxywyyqwmvrrzxvunzvqltovxppyynvylxxlqwwxpxqqs

output:

1225 42 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 

result:

ok 50 numbers

Test #7:

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

input:

50
qpytzpzuzryyyywzwvzrzwvzlqvnysuqosxpwzzwysmvwwwysw

output:

1225 52 3 0 1 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 50 numbers

Test #8:

score: 0
Accepted
time: 6ms
memory: 16448kb

input:

500
wxntkuresxqhrfasoqgmzorcehxjcqooxsncdxgetjstfdpxwjihwfpnqbbioztozfegasscvzswwxmttvwgbxrbsbvkhjbmjwvquzxjinlyzoxhqkuflgihcaudnyoghubfykllruerubkcsmdbzsmknmzexkkvzmkxjrurcloufqcutwjknlohowgtwubymizrvjiiqnrbnxrgvoiwheiydxipsryynhmzoawzmyhxwwqizehnvvrgpbntaaggpqolumkjeduxxfxtgdbngmlwjbozgvztsgnndwhm...

output:

124750 2304 67 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 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 500 numbers

Test #9:

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

input:

500
szylxznqzzpzxwxtzvvrxyvyzytsvzsvswsumqyvzpzzqsywwwzsxutupzuwwuxwpqympzxowyrzwsvzyymzytuwuprkvtxvxwtzwtzxtrttvzwszzstuqtxyzmpoxytwvvyuvszuryyqytozysztrpvmxzzzsxxpjwtryowynsytkyzyzuyslywvvzquvzyzuzxyxnrqtwsvvzuzywtzgzgvznvzxuzvxzxzsyxyszxrjruzuwrzystzzpyqwqxzvytzwxrzysugpwxnyoylxxvxvywmwlywxruxpsu...

output:

124750 5207 325 20 1 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 500 numbers

Test #10:

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

input:

500
yzzyzzyyyxzyzxvszxuyzyxxyzwzzuyzzxvxxyyzzxxzwztzzzywxwzzyxzzxzxvzvzyzyxyzyyzzvtwxyvzzzzyyxvzzuvxyyvzyuyyzzwyzzvzztzwzyyzzvyuzzzzyzzzwwxyxzxvyuuzxzyuzzyxxyuyzxxzyzxzxyzvzxzzyyzxxuzyuvzzyszzwyttszzxyxzwzyxzzyztxyzzxzzzzxxxzzxyzvzwwvztywyxuyuzyzxxuyxzvzxzvrywytwuyvtyxxyxxzzyyvuzvvzwyzzzxsywzyzzwwzz...

output:

124750 12361 1779 287 61 14 3 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 500 numbers

Test #11:

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

input:

500
zzyzzzyzyzyzyxzyzzzyyxzyzzzzzzzzzzxyyzzzzzzzyzzzxyzzzzzzzyyyzzyzxzzyzzzzyzzxzyyzzzzyzwzzzzzyzzzzzzzyzzzzzzzxzzzzzzwzzxyzzzzzzyzzuzyzxzzzyzzxzyzyyzzxzzyyzzzwzyzzyzyzyyzzzzzyzzxyzxzzzzzxzzzwzzyyzzzyyzyxyywzzzzzzzzzyzzzzzzzzzzyzzzzzwzzzyyzyzzyzzzzzyzzzyzzzyzyzzvzzzzzyzzzywzyzzzzzyzzwzzzzyzzyzzzzzzy...

output:

124750 25306 8168 3162 1233 537 219 110 53 18 12 4 0 1 1 0 1 1 1 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 500 numbers

Test #12:

score: 0
Accepted
time: 23ms
memory: 17292kb

input:

2000
uzvwxzqszxwzwypyuzrzzokzrhzyypytsyzvzxuzvruwyvujvzpvtvuuxuyztxzstsyxxuwwxzuzsyuqxsyznwzuwwxpuuvzqwtxwqrxxvytquyjtrzxuzzwyxzzxuwzrtxntyxwxyzvvstyvzpzsvxuztuzqtzvywtxyzxtxxsxpnzxovyzzyvnrwyxyzznlqywzwkzlnswxuyuvztxywmxxyvyqwxwwszzywxnpvvrtyydrwwwzyvsrzytrzrojqrnvojtzvqnnxvxylsywoztzzwvlvwsvvxrzqv...

output:

1999000 86828 5220 320 30 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 2000 numbers

Test #13:

score: 0
Accepted
time: 122ms
memory: 21780kb

input:

10000
rhsrvsyyqzsxonvqxxxryzqwuyzypwiqpsvqvwsvvswowuznznpyxzyzyryuypwyuvrsvxyywwszutzqxjpwzyzzysyyzrmztsusyvtpzrmqrzyxqwusswyywtvporwymwxylzvsilxtyzxssvyllrwvzyxuzxpxyzrwyvwurqyzxwviyuzvzfzzstutuxtsxwyywtvzxrxuztiwpwwvzmvxnvxpvoqyxyyyxzmouztvxwryzzyzszrtrwupsvwyyrxszxywzsyozyynzrlxupprnxwyouyuqsuovu...

output:

49995000 2112858 122779 8113 543 52 2 1 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 10000 numbers

Test #14:

score: 0
Accepted
time: 788ms
memory: 44976kb

input:

50000
ixxzzrxyyvxuxjzyssqmrwyzzwzsnsjpvxyzuwvyusyolxtpxzzlvxiuutwrxyxksywsxuttzztxzvkktvrztxzyzrowwzrzxxruzwzxzqvovuuvywwrvtwyuqqyuwyxzxmzzzzxtrsqrvvzyuyyxtztxpxhozyzxmyvyysvupsyyzwuxzvszxzzqzxkwwvyxuvvxtpztzyyxwuywqsosutyqyuwzyqyxtsvvrptxwqwzumsxxznntvrwyzxxzyqstxuxqqvivmswxyrvxzvwztxpwuzuvtryzvmxy...

output:

1249975000 52455909 3024419 197627 13719 1014 75 10 0 1 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 50000 numbers

Test #15:

score: 0
Accepted
time: 1932ms
memory: 75168kb

input:

100000
yttwuxxrivtyvxpxpwzsvvtuhuwztxuurzxzwuzxzxuynwqzytsyrvzvzxyzzsyqutvxysuyvvvpvyrvxyxrywxxttqxvgpvjuzwovmqpoxtsrxuozvxwyquvszuyyyxvqxvzwwmyyvrzyyzzfyvtxvtztztzzrvrzyyyxrvsrvpzknytxywxrqsvuvzwzyzzyyyizxyiwpcwsyxytvsyuxvmvxxqwxztywwzyyotwxszoxzquwxzywytvvyozxyjrtuuyvmpyuxsuzryylyyzwysyyqxxgqruuvv...

output:

4999950000 209545451 12046079 785540 54925 3991 295 17 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 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 100000 numbers

Test #16:

score: 0
Accepted
time: 3485ms
memory: 105644kb

input:

150000
vuzzzrzykxmvwzzvvomqltufzyunvjjoyzuzqnsyuxttyvvuuypvxxjxxxyzprryxwyzupyuttltxxwwqzxrwuwzzywtztzuvttzpxvoszruxtlrtxuzwzyvzojzvvqsoruszqqwtxzxsqqzuqukphxzxzsvtvvuxvzmtvzrymvtpwpzuttvyyzwwwivvytzxkszrxzsxqwqryuvystztmyztyuwqrrssytolzytsqyysyvyuztzolzvxtunzwuvhzrvrwzxizphspxtnswrkyytyyzvuxyumoonv...

output:

11249925000 469565848 26925274 1744782 121977 8974 673 59 2 1 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 150000 numbers

Test #17:

score: 0
Accepted
time: 5571ms
memory: 128208kb

input:

200000
svvvhqqppfhewxhmeclitlziuowntblgmljpcfgjfaajeixxrmjjuttqpznsmrkiymdfwkfzqqrpketauslquxumajselkqjdztyelhjqtebtquctbbklfiwctosgaspzgkqitpzowfkhvuspnzgagsqviaytknmdmfavkgmmkowhqdtzkzvmfzxyugunddgrvefnfqqoclylvtuhwohmqbvwqdnpjocjdpdnslzfnhraleestxiliiahprzdfnenlrxnodllnpwiyibbezrmcdjgaputdwceotym...

output:

19999900000 377209698 9603666 276150 8570 281 14 1 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 200000 numbers

Test #18:

score: 0
Accepted
time: 5330ms
memory: 136656kb

input:

200000
zuzqwyutyynuuvpyywzxsvsovvlynyttxwzhzqszwtwzqwzysxxfwxyswzurqyonwvvvpwuwpvqnzszzwoyvzzuvwsxqxlxxzxxnqtxwrmzxuzkylnyywvrwyzvwqzquxtqunxrrzxwjzyqwvtrzryvstmxymzvxpywxqtvyxttzrzuuhixvurrrvlwxqwzuzwxirtxrwsuqvyvxtvstkzqwwzotxywhrzplvtlvxvwyyytyryoqyphxsxwvwrvvyvuyzxyywwwyxtwyytmlwyyryuztzyzwyuupz...

output:

19999900000 836271472 47956789 3116604 216013 15637 1158 98 6 1 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 200000 numbers

Test #19:

score: 0
Accepted
time: 5431ms
memory: 147476kb

input:

200000
xzyyxzyzuxzwzzzwxxyxzwsyxvxyyzzxxyxwwtxzyxyyzzvyzxzxwwtwyyzzyxvzxxuzwzywyxzxxuxzzryvvxyzzzyzzzzxzxwzxyyzzzyzxzwtuzwywxwzvvyzzyxzyzzywzzxyyzuyzywwzyxxzzvzuzxyyzytzyzzzszwzxzzzzszyvzyzzzyzzzxyyyzuzwzzyzxzzzzvpztyzxxyxxyxtyxzzzzttyvywyzzyxtuyyywyyyzxxwuvzvzwwzwyyvyxxzyywyzzzzzwwyxvzwyuwyyyyyyyzy...

output:

19999900000 1948144620 272200389 43759959 7562451 1365650 249293 48011 9115 1945 377 66 9 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 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 200000 numbers

Test #20:

score: 0
Accepted
time: 5320ms
memory: 167800kb

input:

200000
zyyzyyzzzzyzzyyzzzzzzzwyzzwzyxzzzzzzzzyzzyyzzzwzzxzzzzzzzzzzyzzzzzyzzyxzzzyzyzzzzzzwzzzzzyzzwzzzzzzyzzzyyyzxzzzxzzzzzxzyyzzzzzyyxxzzzzzxzxyzzzyzzzzzzzzzyzyzzxxzzzzyzzzzxzzyzzzzxzwzzzyzyzzxzzzzzzzzzyyzzzyyzzzzzyyzzzzzzyzyzzzyzzyzzzzzyzzzzzzzzzzzyxzyzzzzzzzyzzzzzzzxzzwzzxzyzzwyzzzzzyzzzxyyyzzyz...

output:

19999900000 3959980692 1257993529 476678310 197946906 86859093 39561937 18237256 8711393 4221673 2075791 995638 497061 250700 131452 65700 32664 16200 8174 4673 2275 1216 571 329 153 99 33 25 9 14 4 5 1 2 0 0 1 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 200000 numbers

Test #21:

score: 0
Accepted
time: 342ms
memory: 52104kb

input:

50000
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...

output:

1249975000 312487500 138869442 78118748 49994998 34715275 25500508 19528123 15426232 12497498 10326237 8675692 7393932 6374232 5552775 4881247 4323267 3854473 3459762 3123747 2831007 2579853 2359875 2168400 1998997 1848000 1712172 1592217 1485223 1386942 1298463 1219138 1146852 1079712 1018875 96257...

result:

ok 50000 numbers

Test #22:

score: 0
Accepted
time: 682ms
memory: 65364kb

input:

100000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

4999950000 1249975000 555527775 312487500 199989997 138869442 102023468 78118750 61721602 49994997 41309502 34715275 29579583 25500509 22214442 19528125 17296018 15426232 13846950 12497497 11331177 10326237 9446028 8675692 7997997 7393932 6854250 6374233 5942625 5552775 5198697 4881250 4588932 43232...

result:

ok 100000 numbers

Test #23:

score: 0
Accepted
time: 1272ms
memory: 109704kb

input:

150000
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

11249925000 2812462498 1249974998 703106248 449984997 312487498 229568878 175771873 138869442 112492497 92963428 78118748 66556950 57389539 49994997 43940623 38918250 34715275 31153668 28121247 25500509 23239150 21258457 19528123 17996997 16637793 15426232 14346044 13372203 12497497 11700700 1098163...

result:

ok 150000 numbers

Test #24:

score: 0
Accepted
time: 1527ms
memory: 107844kb

input:

150000
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

11249925000 2812462479 1249974972 703106215 449984965 312487463 229568840 175771834 138869406 112492462 92963392 78118709 66556911 57389499 49994957 43940584 38918210 34715239 31153630 28121208 25500467 23239111 21258419 19528083 17996958 16637752 15426191 14346003 13372162 12497456 11700660 1098159...

result:

ok 150000 numbers

Test #25:

score: 0
Accepted
time: 2052ms
memory: 180732kb

input:

200000
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

19999900000 4999950000 2222144445 1249975000 799980000 555527778 408136735 312487500 246897531 199990000 165265290 138869445 118326036 102023470 88877778 78118750 69189966 61721605 55393075 49995000 45339003 41309505 37797165 34715278 31996000 29579586 27428121 25500511 23773960 22214445 20804475 19...

result:

ok 200000 numbers

Test #26:

score: 0
Accepted
time: 2024ms
memory: 129356kb

input:

200000
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr...

output:

19999900000 4999949999 2222144444 1249974999 799979999 555527777 408136735 312487499 246897530 199989999 165265290 138869444 118326036 102023469 88877777 78118749 69189965 61721604 55393074 49994999 45339002 41309504 37797164 34715277 31995999 29579585 27428120 25500510 23773959 22214444 20804474 19...

result:

ok 200000 numbers

Test #27:

score: 0
Accepted
time: 2138ms
memory: 167256kb

input:

200000
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...

output:

19999900000 4999949998 2222144443 1249974998 799979997 555527775 408136732 312487497 246897529 199989997 165265287 138869442 118326033 102023467 88877775 78118747 69189964 61721602 55393072 49994997 45339000 41309502 37797162 34715275 31995997 29579583 27428118 25500508 23773957 22214442 20804472 19...

result:

ok 200000 numbers

Test #28:

score: 0
Accepted
time: 2504ms
memory: 121444kb

input:

200000
ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg...

output:

19999900000 4999949984 2222144413 1249974971 799979963 555527740 408136698 312487465 246897490 199989962 165265249 138869407 118325995 102023429 88877735 78118709 69189926 61721561 55393032 49994958 45338959 41309461 37797122 34715237 31995955 29579544 27428077 25500467 23773916 22214401 20804431 19...

result:

ok 200000 numbers

Test #29:

score: 0
Accepted
time: 860ms
memory: 51476kb

input:

50000
dzwtdzmncpwfosbbwlrlraaphgniyqiljuyofdqzbcfknmjpvoybftolhnmzecfspeawustiphkerxtgmriohyriqgozixbdddzprsviaraxbzvogymzgvvxuyhtrwfcvrvmoiibxoodqwgzegbvrvbwwwpkenlcrsqwwovszdirbsneksvotpthsrbhuuylqrwreqddkdjmobcnmdiobvfuyhmgoemfjabmbmaodjdjladmgscetbqdetzkthhupgxirekezanexdpzusdiqwxneutsbmoovqbneh...

output:

1249975000 23586142 599073 23437 5500 21 1 3100 0 2480 0 0 0 0 0 1550 0 0 0 1240 0 0 0 0 992 0 0 0 0 0 800 775 0 0 0 0 0 0 0 620 0 0 0 0 0 0 0 0 0 496 0 0 0 0 0 0 0 0 0 0 0 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 248 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 50000 numbers

Test #30:

score: 0
Accepted
time: 1922ms
memory: 87440kb

input:

100000
hmqckpztbvideyvwtvgdvbyflbkajhmfoytvqdctycjmpssqzscpteszsgwueyznhhrdzcbttqgpyqirudgtnqmaqzxrcqhmocdhtvhzkgdnguturxomrygwcenrxsdscxrsikngpzserdwbuipyzlyleiqflkiiafqphdqycbplhessusuhiatoqzrhcfsfugzgfausickfpiovlsrxtqjvbfdafolkmuogmbvaticwajbibklulhikragrlbkohzwelquqyujlwfgtpjwrxnvsndbxhnzzdrjao...

output:

4999950000 94326289 2417542 81557 12050 8340 4 6225 0 4980 0 4150 0 0 3320 0 0 0 0 2490 0 0 0 2075 1992 0 0 0 0 1660 0 0 0 0 0 0 0 0 0 1245 0 0 0 0 0 0 0 0 0 996 0 0 0 0 0 0 0 0 0 830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 664 0 0 0 0 0 0 0 600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 498 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 100000 numbers

Test #31:

score: 0
Accepted
time: 3501ms
memory: 99488kb

input:

150000
omgqrakgnpelbssesmphwhepzglbuxpviuaatmfwbtbobdwbywhlndxgghnxrsqvepkvtzqdkacftmnvkztkwnjvqotfwbaexnolwrernlynehjwwpleobwwbjievmpmfoxegjxisamcxgfychetqdzqljovtdawhkuwqujtivwlnyloxopbfqtjpvteabptwengeejyhbdrbixrzvhcymwhlgmutkocaaclbivbfmmivwumvpwnuvcvcdqmssmxwjcvvylmoodrlpkzhhadibcfgsahunefwuavl...

output:

11249925000 212181738 5405078 155833 5000 157 5 125 0 100 0 0 76 0 0 62 0 0 0 50 0 0 0 0 40 37 0 0 0 0 0 0 0 0 0 0 0 0 0 25 0 0 0 0 0 0 0 0 0 20 0 18 0 0 0 0 0 0 0 0 0 0 0 0 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0...

result:

ok 150000 numbers

Test #32:

score: 0
Accepted
time: 3555ms
memory: 122992kb

input:

150000
ugpwsjjlhmaopuqvkrrijuvkbcxcwllyrovfuxtyfedmqrnpmetepxcosjtwnscxmhextwqnsmvqmdprpqoqaxbvwkmrduzsczcnjspewjkyesdnjkmspzlyvkcswnkonvpzudkdxqvdjixrjxsmvrceqjoruvwqccthbhnhhikhtjiensylfnpyvdnuoslrmzbdyadzlrfgaffzgmtzgdeoqntxceqtcotbjezahcyvkrkqpemttbnoqcilgznqwilofpbkrnrqhdclufqjqltjmyhfhtrbuiyno...

output:

11249925000 212190318 5406309 174086 19846 141 4 9350 0 7480 6800 0 0 0 0 4675 4400 0 0 3740 0 3400 0 0 2992 0 0 0 0 0 0 0 0 2200 0 0 0 0 0 1870 0 0 0 1700 0 0 0 0 0 1496 0 0 0 0 1360 0 0 0 0 0 0 0 0 0 0 0 0 1100 0 0 0 0 0 0 0 0 0 0 0 935 0 0 0 0 880 0 0 850 0 0 0 0 0 0 0 0 0 0 0 748 0 0 0 0 0 0 0 0...

result:

ok 150000 numbers

Test #33:

score: 0
Accepted
time: 5639ms
memory: 128428kb

input:

200000
dqudajreffiwgtmmlhkykznxicdkjoinyhhfusivwqrbdjufhlwuesnalsweulueejbckyyqcghnatvdkzsbnuacknzmjpaqrbcseaualbhparbmsyysienbxyutlzhhlhsubsifhigwptqmrlsevirlwasktkmigacfoiqrsptgccwwdabvcwmivieiectgnftcgzlmsgsmlunmlsgowvyeaxkgqusmysvqdrvtmojjyhknxijutljmhhsiwymsqsydtvdkditvwrzhgilvvakaanwmyipcpkorb...

output:

19999900000 377214246 9606852 275830 8781 265 6 125 0 100 91 0 0 0 0 0 0 0 0 50 0 45 0 0 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 0 0 0 22 0 0 0 0 0 20 0 0 0 0 18 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 11 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 ...

result:

ok 200000 numbers

Test #34:

score: 0
Accepted
time: 5730ms
memory: 131092kb

input:

200000
oexjgkocppkldnbgixayqehmovixuntjpwqcykpslbpwzkcgveuumqeutfiquusqgpshuvwejgzfkpadyaskkqselyrbqxhgcmsdeqfkckkpobltpxwvsecwchhrietpknzwidkjzuhsifybfpqcfwddrxnpjokpfifbtogzczsjmhmxuokklxdrjqvhjrqiebiezacxqtawqztkuhqlwrsdminhinmytnfokmnnafsjesigenshuhospgggzvkpxtxyykirnzcnnpanzfcvtaxirlddqsfvkynjx...

output:

19999900000 377259156 9605422 278482 10314 294 13 1251 0 1000 0 0 0 0 0 625 0 0 0 500 0 0 0 0 400 0 0 0 0 0 0 312 0 0 0 0 0 0 0 250 0 0 0 0 0 0 0 0 0 200 0 0 0 0 0 0 0 0 0 0 0 0 0 155 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 200000 numbers

Test #35:

score: 0
Accepted
time: 5382ms
memory: 158972kb

input:

200000
fvxwkfaizlkcqoaafxbzbmrujfkwrnrftdwgoppksxtfjjgajjyzyrwvwunazaxqcgjdygnzpqwkekrhgpwbtifabyisaeudpgtjqdqqnmwgbwcypniffujstvwgotdhfdumtanaoalrieglwsoebffvdfhhwejbdicnyonjvqnvosfjigeifbphonpyacczqlwqpckwkppynsxhtgltidbrlxrxcedxzasasphgecrdekxdalgafduuxbnplfxkpdvtdoywqpduohcpmexlealrjpdrjliooqqfu...

output:

19999900000 377267425 9610456 302219 28648 274 11 12479 0 9980 0 0 0 0 0 0 0 0 0 4990 0 0 0 0 3992 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2495 0 0 0 0 0 0 0 0 0 1996 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 998 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 200000 numbers

Test #36:

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

input:

50
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

output:

1225 300 120 66 45 28 21 15 10 10 6 6 3 3 3 3 1 1 1 1 1 1 1 1 1 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 50 numbers

Test #37:

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

input:

50
baabaabbabbbaabaaababaaabaaabbbaaaaaabbbbbabaabaaa

output:

1225 227 58 18 7 3 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 50 numbers

Test #38:

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

input:

50
ccbcccccccbbcccacaccaccbcaacbcaacccbbcbbcbbbbcbbab

output:

1225 184 46 13 4 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 50 numbers

Test #39:

score: 0
Accepted
time: 1796ms
memory: 118032kb

input:

200000
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

19999900000 4999950000 2222144445 1249975000 799980000 555527778 408136735 312487500 246897531 199990000 165265290 138869445 118326036 102023470 88877778 78118750 69189966 61721605 55393075 49995000 45339003 41309505 37797165 34715278 31996000 29579586 27428121 25500511 23773960 22214445 20804475 19...

result:

ok 200000 numbers

Test #40:

score: 0
Accepted
time: 5201ms
memory: 188480kb

input:

200000
bbaaaabbaaabaababaabaabbbababbabbaaabbabbbbbabbabbabbbabbbababaabaaabaabaabbbabbabbbbababaabaaabbbaabaaabaaabaaabbbbbbaabbabbabbabbaaaaaaabbaaabbabbbabaabbbbaaaababbbbaaaaabbaabbbbbbabbababbbabbbbaabbbaaaababbaaabbbbaaababbbbaaaabaabaaaabbabbbabbaabbbaabbababababbaaaaaaaabaaabaabbbabaabbaaaab...

output:

19999900000 3749950502 1111125637 390588937 149989554 60768856 25505026 10987543 4822749 2150535 968303 440514 201916 93120 42989 20184 9680 4499 2030 982 486 221 118 52 26 8 6 2 0 1 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 200000 numbers

Test #41:

score: 0
Accepted
time: 5163ms
memory: 188488kb

input:

200000
bbbbbbbbbbbabbabbbbbbbbbbbbbbbbababbbababbbbbabbbabbbbabbbbbbabbbbbbbbababbbbbbbbbbbbbbbbbbabbbbbbbbaabbbabbbbabbbbbbbbbbbbbabbbabbbbbbbbababbbbbabbabbbbbbbbbbbbbbbbbbbabbbabbbabbbbabbbbbbbbaaabbbabbbbbbbbbbbbbbbabbbbbbbbabbbaabbbabbbbbabbbabbbbabbbabbbbbbbbbabbbbbbbbbbabbbbababbbbbbbbbbababb...

output:

19999900000 4763278864 1953231235 990222399 561005173 340657311 216274672 141618889 95072412 65004435 44980037 31493965 22466696 15869621 11598144 8215035 6029467 4421298 3234843 2406589 1769083 1277618 950862 663729 516603 404589 302575 219346 161018 128457 90807 65092 50295 40871 27234 21113 16725...

result:

ok 200000 numbers

Test #42:

score: 0
Accepted
time: 5464ms
memory: 167660kb

input:

200000
aacacaabcbbbcccacaaacccaccacbbabbbbaaaaacbcababcbbcbcbbaaaabaabcaabccabbcccabcccaccbabaacaaacaaacbaabcbaabaaaaaabaacabbbbbbcabacaabbcaacaaabacbcccbabaccbbbcbabcbaacabbaaacacbccccabacabbcabbbaaacbbabaacbabbbbbcbccabacbcaacbbcabaabcbbbbcaccbcacbaccbabcabccccaabaaabcaabcbcbcbcbaccbcacabbcbcaacab...

output:

19999900000 2777751571 576096749 138880202 36219144 9903348 2801527 810256 238637 71054 21264 6654 2016 564 198 83 19 9 2 3 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 200000 numbers

Test #43:

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

input:

50
mwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmwxmw

output:

1225 92 120 18 12 28 5 3 10 2 1 6 0 0 3 0 0 1 0 0 1 0 0 1 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 50 numbers

Test #44:

score: 0
Accepted
time: 2110ms
memory: 114444kb

input:

200000
gjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjgjg...

output:

19999900000 4999950000 1111055556 1249975000 399980000 555527778 204061225 312487500 123443210 199990000 82628100 138869445 59159172 102023470 44435556 78118750 34592042 61721605 27693906 49995000 22667121 41309505 18896409 34715278 15996000 29579586 13712209 25500511 11885256 22214445 10400625 1952...

result:

ok 200000 numbers

Test #45:

score: 0
Accepted
time: 3681ms
memory: 140568kb

input:

200000
tvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvtvt...

output:

19999900000 4999949376 1111055152 1249974064 399979505 555526749 204060696 312486420 123442677 199988884 82627559 138868318 59158613 102022332 44434985 78117601 34591463 61720451 27693333 49993830 22666547 41308339 18895829 34714109 15995412 29578406 13711628 25499325 11884659 22213258 10400035 1952...

result:

ok 200000 numbers

Test #46:

score: 0
Accepted
time: 2498ms
memory: 113192kb

input:

200000
umqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqumqum...

output:

19999900000 1666616667 2222144445 416641667 266646667 555527778 136036055 104154167 246897531 66656667 55082370 138869445 39436884 34003062 88877778 26035417 23059401 61721605 18460850 16661667 45339003 13766805 12596157 34715278 10662667 9857298 27428121 8497790 7922355 22214445 6932675 6507292 183...

result:

ok 200000 numbers

Test #47:

score: 0
Accepted
time: 3735ms
memory: 135924kb

input:

200000
uicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicuicui...

output:

19999900000 1666649847 2222143721 416641409 266646381 555526889 136035749 104153861 246896561 66656310 55082037 138868460 39436544 34002737 88876764 26035078 23059066 61720580 18460518 16661327 45337965 13766453 12595813 34714242 10662341 9856967 27427078 8497437 7922020 22213409 6932323 6506947 183...

result:

ok 200000 numbers

Test #48:

score: 0
Accepted
time: 2847ms
memory: 111852kb

input:

200000
rsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehnwrsjehn...

output:

19999900000 714235715 317420636 178546429 114265715 79346826 408136735 44630358 35261553 28561429 23601536 19831350 16897127 102023470 12691112 11154465 9879240 8812611 7908786 7137858 45339003 5897463 5395869 4955755 4567429 4222359 3915129 25500511 3393325 3170636 2969304 2787054 2620085 2468340 1...

result:

ok 200000 numbers

Test #49:

score: 0
Accepted
time: 4170ms
memory: 134208kb

input:

200000
ccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwqtccegwq...

output:

19999900000 1122429483 317430047 178546287 114265579 79346700 408135733 44630170 35261398 28561262 23601355 19831193 16896981 102022380 12690942 11154299 9879081 8812451 7908626 7137706 45337881 5897300 5395711 4955593 4567278 4222185 3914972 25499375 3393170 3170465 2969151 2786884 2619936 2468168 ...

result:

ok 200000 numbers

Test #50:

score: 0
Accepted
time: 3212ms
memory: 110892kb

input:

200000
fenfhxoomthoaauxqsojnixexzecuhaineqekknrzfeopvupcsazfenfhxoomthoaauxqsojnixexzecuhaineqekknrzfeopvupcsazfenfhxoomthoaauxqsojnixexzecuhaineqekknrzfeopvupcsazfenfhxoomthoaauxqsojnixexzecuhaineqekknrzfeopvupcsazfenfhxoomthoaauxqsojnixexzecuhaineqekknrzfeopvupcsazfenfhxoomthoaauxqsojnixexzecuhain...

output:

19999900000 650847042 49276234 96128847 15364620 21350428 7834779 24025962 4737138 7682310 3169269 10674573 29575740 3917115 1702656 6003367 1324812 2368569 1060096 3841155 867237 1584460 722609 2666560 611388 14787870 523838 1958283 453816 851200 396924 1499280 350088 662406 311086 1184071 278203 5...

result:

ok 200000 numbers

Test #51:

score: 0
Accepted
time: 4110ms
memory: 170972kb

input:

200000
mffggjgyhawgmcfsckucdbzycdsbeprnsyxvwugapfxzbhjeizbemffggjgyhawgmcfsckucdbzycdsbeprnsyxvwugapfxzbhjeizbemffggjgyhawgmcfsckucdbzycdsbeprnsyxvwugapfxzbhjeizbemffggjgyhawgmcfsckucdbzycdsbeprnsyxvwugapfxzbhjeizbemffggjgyhawgmcfsckucdbzycdsbeprnsyxvwugapfxzbhjeizbemffggjgyhawgmcfsckucdbzycdsbeprns...

output:

19999900000 488176608 57496412 96128761 15364595 21350390 7834757 24025866 4737119 7682263 3169247 10674484 29575461 3917063 1702634 6003277 1324793 2368526 1060078 3841048 867216 1584424 722585 2666468 611363 14787272 523817 1958200 453792 851155 396906 1499199 350065 662360 311071 1183991 278182 5...

result:

ok 200000 numbers

Test #52:

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

input:

16
abbabaabbaababba

output:

120 12 9 2 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 16 numbers

Test #53:

score: 0
Accepted
time: 4485ms
memory: 174236kb

input:

200000
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbab...

output:

19999900000 2499950000 1126698715 624975000 177829510 95181272 36839491 156237500 14124090 16677641 6877779 24006650 4101333 5662362 2576906 39056250 1696473 2694846 1149008 4171580 903993 1430009 651995 6071972 497746 818050 398950 1414801 306309 573655 257037 9762500 219374 365438 168131 682925 14...

result:

ok 200000 numbers