QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#219383#5037. 回文chenxinyang200620 3878ms69108kbC++1414.7kb2023-10-19 13:58:542023-10-19 13:58:54

Judging History

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

  • [2023-10-19 13:58:54]
  • 评测
  • 测评结果:20
  • 用时:3878ms
  • 内存:69108kb
  • [2023-10-19 13:58:54]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
#define mod 998244853
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}

template <int P>
class mod_int
{
    using Z = mod_int;

private:
    static int mo(int x) { return x < 0 ? x + P : x; }

public:
    int x;
    int val() const { return x; }
    mod_int() : x(0) {}
    template <class T>
    mod_int(const T &x_) : x(x_ >= 0 && x_ < P ? static_cast<int>(x_) : mo(static_cast<int>(x_ % P))) {}
    bool operator==(const Z &rhs) const { return x == rhs.x; }
    bool operator!=(const Z &rhs) const { return x != rhs.x; }
    Z operator-() const { return Z(x ? P - x : 0); }
    Z pow(long long k) const
    {
        Z res = 1, t = *this;
        while (k)
        {
            if (k & 1)
                res *= t;
            if (k >>= 1)
                t *= t;
        }
        return res;
    }
    Z &operator++()
    {
        x < P - 1 ? ++x : x = 0;
        return *this;
    }
    Z &operator--()
    {
        x ? --x : x = P - 1;
        return *this;
    }
    Z operator++(int)
    {
        Z ret = x;
        x < P - 1 ? ++x : x = 0;
        return ret;
    }
    Z operator--(int)
    {
        Z ret = x;
        x ? --x : x = P - 1;
        return ret;
    }
    Z inv() const { return pow(P - 2); }
    Z &operator+=(const Z &rhs)
    {
        (x += rhs.x) >= P && (x -= P);
        return *this;
    }
    Z &operator-=(const Z &rhs)
    {
        (x -= rhs.x) < 0 && (x += P);
        return *this;
    }
    Z operator-()
    {
        return -x;
    }
    Z &operator*=(const Z &rhs)
    {
        x = 1ULL * x * rhs.x % P;
        return *this;
    }
    Z &operator/=(const Z &rhs) { return *this *= rhs.inv(); }
#define setO(T, o)                                  \
    friend T operator o(const Z &lhs, const Z &rhs) \
    {                                               \
        Z res = lhs;                                \
        return res o## = rhs;                       \
    }
    setO(Z, +) setO(Z, -) setO(Z, *) setO(Z, /)
#undef setO
    
    friend istream& operator>>(istream& is, mod_int& x)
    {
        long long tmp;
        is >> tmp;
        x = tmp;
        return is;
    }
    friend ostream& operator<<(ostream& os, const mod_int& x)
    {
        os << x.val();
        return os;
    }
};

using Z = mod_int<mod>;
Z power(Z p,ll k){
    Z ans = 1;
    while(k){
        if(k % 2 == 1) ans *= p;
        p *= p;
        k /= 2;
    }
    return ans;
}

ull seed = 'x' + 'a' + 'y' + 't' + 'x' + 'd' + 'y';
ull rnd(){
	seed = seed * 1145141 + 1011451423;
	return seed;
}

int n,Q;
char s[200005];
ull P[2][200005];
Z eP[2][200005];

#define base 127
#define ibase 9150747060186627967llu

const int B = 447;
inline int from(int x){return (x + B - 1) / B;}
inline int L(int x){return x * B - B + 1;}
inline int R(int x){return x * B;}
ull val[2][300005],tag[2][550];
Z eval[2][300005],etag[2][550];
void init(){
	rep(i,1,n) val[0][i] = val[0][i - 1] + P[0][i] * s[i];
	rep(i,1,n) val[1][i] = val[1][i - 1] + P[0][i] * s[n + 1 - i];

	rep(i,1,n) eval[0][i] = eval[0][i - 1] + eP[0][i] * s[i];
	rep(i,1,n) eval[1][i] = eval[1][i - 1] + eP[0][i] * s[n + 1 - i];
}

void upd(int op,int pos,ull C){
	int fp = from(pos);
	rep(k,pos,R(fp)) val[op][k] += C;
	rep(k,fp + 1,from(n)) tag[op][k] += C;
}

ull qry(int op,int pos){
	return val[op][pos] + tag[op][from(pos)];
}

//
void eupd(int op,int pos,Z C){
	int fp = from(pos);
	rep(k,pos,R(fp)) eval[op][k] += C;
	rep(k,fp + 1,from(n)) etag[op][k] += C;	
}

Z eqry(int op,int pos){
	return eval[op][pos] + etag[op][from(pos)];	
}
//

void mdf(int pos,int C){
	upd(0,pos,P[0][pos] * C);
	upd(1,n - pos + 1,P[0][n - pos + 1] * C);

	eupd(0,pos,eP[0][pos] * C);
	eupd(1,n - pos + 1,eP[0][n - pos + 1] * C);
}

int rev;//rev 表示查询的都是反信息
int curL,curR;
ull _getval(int l,int r){
	return (qry(0,r) - qry(0,l - 1)) * P[1][l];
}

ull _getvalrev(int l,int r){
	l = n - l + 1;r = n - r + 1;
	swap(l,r);
	return (qry(1,r) - qry(1,l - 1)) * P[1][l];
}

//
Z _egetval(int l,int r){
	return (eqry(0,r) - eqry(0,l - 1)) * eP[1][l];	
}

Z _egetvalrev(int l,int r){
	l = n - l + 1;r = n - r + 1;
	swap(l,r);
	return (eqry(1,r) - eqry(1,l - 1)) * eP[1][l];	
}
//

int check(int l,int r){
	if(l < curL || r > curR) return 0;
	if(rev){
		l = n - l + 1;r = n - r + 1;
		swap(l,r);
	}
	return (_getval(l,r) == _getvalrev(l,r)) && (_egetval(l,r) == _egetvalrev(l,r));
}

ull getval(int l,int r){
	if(l < curL || r > curR) return rnd();

	if(rev) return _getvalrev(n - r + 1,n - l + 1);
	return _getval(l,r);
}

ull getvalrev(int l,int r){
	if(l < curL || r > curR) return rnd();

	if(rev) return _getval(n - r + 1,n - l + 1);
	return _getvalrev(l,r);
}

ull getval2(int l,int d){
	return getval(l,l + d - 1);
}

ull getvalrev2(int r,int d){
	return getvalrev(r - d + 1,r);
}

Z egetval(int l,int r){
	if(l < curL || r > curR) return rnd();

	if(rev) return _egetvalrev(n - r + 1,n - l + 1);
	return _egetval(l,r);
}

Z egetvalrev(int l,int r){
	if(l < curL || r > curR) return rnd();

	if(rev) return _egetval(n - r + 1,n - l + 1);
	return _egetvalrev(l,r);
}

Z egetval2(int l,int d){
	return egetval(l,l + d - 1);
}

Z egetvalrev2(int r,int d){
	return egetvalrev(r - d + 1,r);
}

int check2(int l,int r){//拓展到右端点 curR
	return check(l + r - curR,curR);
}

struct info{
	int l,r,d;
};

struct node{
	vector <info> pre,suf;//维护所有起始终止点
	int l,r;
}tree[530005];
#define ls (rt * 2)
#define rs (rt * 2 + 1)

int __frp;
int m;
info tmp[205];
void maintain(vector <info> &S){
	m = 0;
	if(__frp){
		cerr << "before maintain\n";
		for(info I:S) cerr << I.l << " " << I.r << " " << I.d << endl;
	}


	for(info I:S){
		if(I.l == I.r) I.d = 0;
		if(!m){
			tmp[++m] = I;
			continue;
		}
		if(!tmp[m].d || tmp[m].d == tmp[m].l - I.r){
			tmp[m].d = tmp[m].l - I.r;
			tmp[m].l = I.r;
			if(I.d) I.r -= I.d;
			else continue;
			if(I.l == I.r) I.d = 0;
		}else{
			tmp[++m] = I;
			continue;
		}
//		cerr << "tm\n";
//		cerr << I.l << " " << I.r << " " << I.d << endl;
		if(tmp[m].l - I.r == tmp[m].d){
			tmp[m].l = I.l;
			continue;
		}else{
			tmp[++m] = I;
		}
	}
	S.clear();
	rep(i,1,m) S.eb(tmp[i]);

	if(__frp){
		cerr << "result:\n";
		rep(i,1,m) cerr << tmp[i].l << " " << tmp[i].r << " " << tmp[i].d << endl;		
	}

}

vector <info> answer;
void mrg(node &p,node &q){
	assert(p.r + 1 == q.l);
	if(__frp){
		cerr << '[' << p.l << "," << p.r << "] [" << q.l << "," << q.r << "]\n";
		cerr << "psuf\n";
		for(info I:p.suf) cerr << I.l << " " << I.r << " " << I.d << endl;
		cerr << "qpre\n";
		for(info I:q.pre) cerr << I.l << " " << I.r << " " << I.d << endl;
		cerr << "qsuf\n";
		for(info I:q.suf) cerr << I.l << " " << I.r << " " << I.d << endl;		
	}


	answer = q.suf;
	info cur = answer.back();
	if(cur.l == q.l){
		if(cur.l == cur.r){
			answer.pop_back();
		}else{
			cur.l += cur.d;
			answer.pop_back();
			answer.eb(cur);
		}
	}

	curL = p.l;curR = q.r;
	int pl,pr,k,pos;
	reverse(q.pre.begin(),q.pre.end());
	for(info I:q.pre){
		if(I.l == I.r){
			pl = q.l - (q.r - I.l);
			pr = q.r;
//			if(__frp) cerr << "check range" << pl << " " << pr << endl;
			if(check(pl,pr)) answer.push_back({pl,pl,0});
			continue;
		}
		k = (I.r - I.l) / I.d;
		pl = I.r + 1;pr = q.r;
		if(pr - pl + 1 <= I.d && getval(I.l + 1,I.l + 1 + pr - pl) == getval(pl,pr) && egetval(I.l + 1,I.l + 1 + pr - pl) == egetval(pl,pr)){//[pl,pr] 是 [I.l + 1,I.l + I.d] 的前缀
			pos = 0;
//			if(__frp) cerr << p.r << " " << I.l + 1 << endl;
			per(_k,__lg(k),0) if(pos + (1 << _k) <= k && getvalrev2(p.r,(pos + (1 << _k)) * I.d) == getval2(I.l + 1,(pos + (1 << _k)) * I.d) && egetvalrev2(p.r,(pos + (1 << _k)) * I.d) == egetval2(I.l + 1,(pos + (1 << _k)) * I.d)) pos += 1 << _k;
//			if(__frp) cerr << getvalrev2(8,6) << " " << getval2(10,6) << endl << "!!" << pos << endl;
//			if(__frp) cerr << "prefix! " << pos << endl;
			if(pl > pr || (getvalrev2(p.r - pos * I.d,pr - pl + 1) == getval(pl,pr) && egetvalrev2(p.r - pos * I.d,pr - pl + 1) == egetval(pl,pr))) pos++;
			pos--;
			pos = k - pos;
//			if(__frp) cerr << pos << endl;
			if(pos <= k) answer.push_back({q.l + I.l - q.r + pos * I.d,q.l + I.l - q.r + k * I.d,I.d});
		}else{
			pos = 0;
			per(_k,__lg(k),0) if(pos + (1 << _k) <= k && getvalrev2(p.r,(pos + (1 << _k)) * I.d) == getval2(I.l + 1,(pos + (1 << _k)) * I.d) && egetvalrev2(p.r,(pos + (1 << _k)) * I.d) == egetval2(I.l + 1,(pos + (1 << _k)) * I.d)) pos += 1 << _k;
			if(check2(q.l,I.l + I.d * (k - pos))){
				pl = q.l + I.l + I.d * (k - pos) - q.r;
				answer.push_back({pl,pl,0});
			}
		}
	}
	reverse(q.pre.begin(),q.pre.end());
	if(check2(p.r,q.l)){
		pl = p.r + q.l - q.r;
		answer.push_back({pl,pl,0});
	}
	if(__frp){
		cerr << "partical result:\n";
		for(info I:answer) cerr << I.l << " " << I.r << " " << I.d << endl;		
	}
	for(info I:p.suf){
		if(I.l == I.r){
			pl = I.l + p.r - q.r;
			pr = q.r;
//			cerr << "check " << pl << " " << pr << endl;
			if(check(pl,pr)) answer.push_back({pl,pl,0});
			continue;
		}
		k = (I.r - I.l) / I.d;
		pos = 0;
		per(_k,__lg(k),0) if(pos + (1 << _k) <= k && getvalrev2(I.r - 1,(pos + (1 << _k)) * I.d) == getval2(q.l,(pos + (1 << _k)) * I.d) && egetvalrev2(I.r - 1,(pos + (1 << _k)) * I.d) == egetval2(q.l,(pos + (1 << _k)) * I.d)) pos += 1 << _k;
		pl = q.l + pos * I.d;
		pr = q.r;
		if(pr - pl + 1 <= I.d && getvalrev2(I.r - 1,pr - pl + 1) == getval(pl,pr) && egetvalrev2(I.r - 1,pr - pl + 1) == egetval(pl,pr)){
			if(__frp) cerr << "!!" << pos << endl;
			if(k - pos > 0) answer.push_back({I.r - (k - pos - 1) * I.d + p.r - q.r,I.r + p.r - q.r,I.d});
		}

		if(check2(I.r - (k - pos) * I.d,p.r)){
			pl = I.r - (k - pos) * I.d + p.r - q.r;
			answer.push_back({pl,pl,0});
		}
	}
/*	if(__frp){
		cerr << "result:\n";
		for(info I:answer) cerr << I.l << " " << I.r << " " << I.d << endl;		
	}*/
	maintain(answer);
	if(__frp){
		cerr << "result:\n";
		for(info I:answer) cerr << I.l << " " << I.r << " " << I.d << endl;		
	}
}

void rever(vector <info> &p){
	for(info &I:p){
		I.l = n + 1 - I.l;
		I.r = n + 1 - I.r;
		swap(I.l,I.r);
	}
}

node operator +(node &p,node &q){
	node ans;
	rev = 0;
	ans.l = curL = p.l;ans.r = curR = q.r;
//	if(p.l == 2 && q.r == 15) __frp = 1;
//	else __frp = 0;
	if(__frp) cerr << "merge suffix:\n";
	mrg(p,q);
	ans.suf = answer;
	
//	__frp = 0;
/*	if(p.l == 1 && q.r == 4){
		__frp = 1;
		cerr << "merge prefix:\n";
	}*/
//	__frp = 0;
	if(__frp) cerr << "merge prefix:\n";
	node tp = p,tq = q;
	rever(tp.pre);rever(tp.suf);
	rever(tq.pre);rever(tq.suf);
	swap(tp.pre,tq.suf);
	swap(tp.suf,tq.pre);
	tp.l = n + 1 - tp.l;tp.r = n + 1 - tp.r;
	tq.l = n + 1 - tq.l;tq.r = n + 1 - tq.r;
	swap(tp.l,tq.r);swap(tp.r,tq.l);
	rev = 1;
	mrg(tp,tq);

	rever(answer);
	ans.pre = answer;
	return ans;
}

void print(node &p){
	cerr << "range [" << p.l << "," << p.r << "] info\n";
	cerr << "pre palin\n";
	for(info I:p.pre) cerr << I.l << " " << I.r << " " << I.d << endl;
	cerr << "suf palin\n";
	for(info I:p.suf) cerr << I.l << " " << I.r << " " << I.d << endl; 
}

void vertify(int rt,int l,int r){
	rev = 0;
	curL = l;curR = r;
	for(info I:tree[rt].pre){
		if(!I.d) I.d = 114514;
		int pos = I.l;
		while(pos <= I.r){
			assert(l <= pos && pos <= r);
			if(!check(l,pos)) printf("fail vertify!! [%d,%d] %d %d\n",l,r,l,pos);
			assert(check(l,pos));
			pos += I.d;
		}
	}
	for(info I:tree[rt].suf){
		if(!I.d) I.d = 114514;
		int pos = I.r;
		while(pos >= I.l){
			assert(l <= pos && pos <= r);
			if(!check(pos,r)) printf("fail vertify!! [%d,%d]\n",l,r);
			assert(check(pos,r));
			pos -= I.d;
		}
	}
}

void build(int rt,int l,int r){
	if(l == r){
		tree[rt].l = tree[rt].r = l;
		tree[rt].pre.push_back({l,l,0});
		tree[rt].suf.push_back({l,l,0});
//		print(tree[rt]);
		return;
	}
	int mid = (l + r) >> 1;
	build(ls,l,mid);build(rs,mid+1,r);
	tree[rt] = tree[ls] + tree[rs];
//	vertify(rt,l,r);
//	print(tree[rt]);
}

void modify(int rt,int l,int r,int pos){
	if(l == r){
		tree[rt].l = tree[rt].r;
		tree[rt].pre.clear();tree[rt].suf.clear();
		tree[rt].pre.push_back({l,l,0});
		tree[rt].suf.push_back({l,l,0});
		return;
	}
	int mid = (l + r) >> 1;
	if(pos <= mid) modify(ls,l,mid,pos);
	else modify(rs,mid+1,r,pos);
	tree[rt] = tree[ls] + tree[rs];
}

node result;
void query(int rt,int l,int r,int L,int R){
	if(l == L && r == R){
		if(!result.l) result = tree[rt];
		else result = result + tree[rt];
		return;
	}
	int mid = (l + r) >> 1;
	if(R <= mid){
		query(ls,l,mid,L,R);
	}else if(L > mid){
		query(rs,mid+1,r,L,R);
	}else{
		query(ls,l,mid,L,mid);
		query(rs,mid+1,r,mid+1,R);
	}
}

int solve(int l,int r){
//	__frp = 1;
	result.l = result.r = 0;
	query(1,1,n,l,r);
//	__frp = 0;
	int _result = 0;
	for(info I:result.suf){
		if(I.d) _result += (I.r - I.l) / I.d + 1;
		else _result++;
	}

	curL = l;curR = r;
	rev = 0;
	for(info I:result.suf){
		if(!I.d) I.d = 114514;
		int pos = I.l;
		while(pos <= I.r){
			assert(check(pos,r));
//			printf("%d\n",pos);
			pos += I.d;
		}
	}
	return _result;
}

int main(){
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	scanf("%s",s + 1);
	n = strlen(s + 1);
	P[0][0] = P[1][0] = 1;
	eP[0][0] = eP[1][0] = 1;
	rep(i,1,n){
		P[0][i] = P[0][i - 1] * base;
		P[1][i] = P[1][i - 1] * ibase;

		eP[0][i] = eP[0][i - 1] * base;
		eP[1][i] = eP[1][i - 1] / base;
	}
	init();
	build(1,1,n);
//	printf("qwq\n");

	int lastans = 0,op,l,r;
	char ch;
	scanf("%d",&Q);
	rep(i,1,Q){
		scanf("%d",&op);
		if(op == 1){
			scanf("%d",&l);
			l ^= lastans;
			assert(1 <= l && l <= n);
			do{
				scanf("%c",&ch);
			}while(ch < 'a' || ch > 'z');
			mdf(l,ch - s[l]);
			s[l] = ch;
			modify(1,1,n,l);
		}else{
			scanf("%d%d",&l,&r);
			l ^= lastans;r ^= lastans;
			assert(1 <= l && l <= r && r <= n);
			lastans = solve(l,r);
			printf("%d\n",lastans);
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 32ms
memory: 41596kb

input:

aabbbabbbaaaaaaabbabbbaaaabaaaabbaabbaabbaaababbbabbbbabbbbaaaabbbabbbbbaaabbbabbaaaaabbbbbaaababbabbaaaaabaabbbbaaababaaabbaabbabbbabbbbaaaaabbbbbbbabbbaabbbabbabbbababbabbbbaaaaabbaababbbbaabbaaaaaabaaabbbaaababbbbaabaaaaababababbbbbbaaaabbbbaaababaaabbaabbbbbaaaabbaaaabaaaaaababbababaaaabaaababaa...

output:

2
3
5
3
3
3
2
3
4
2
4
2
4
2
3
3
3
2
2
2
2
2
2
3
4
2
2
3
2
2
4
3
3
2
3
3
4
3
3
4
4
2
3
4
2
2
4
2
4
3
2
2
2
3
3
3
4
4
3
3
2
3
3
2
3
3
4
2
2
4
2
3
2
3
3
2
3
2
2
3
2
2
3
6
2
2
3
7
4
3
2
2
2
2
3
4
4
4
4
2
2
3
2
4
2
2
2
3
3
2
2
2
2
3
3
4
3
2
3
3
2
2
4
5
4
2
2
5
3
3
3
3
2
4
2
3
2
3
3
3
2
4
4
5
2
2
3
5
3
3
...

result:

ok 2509 tokens

Test #2:

score: 0
Accepted
time: 108ms
memory: 41696kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

188
1078
673
914
360
4255
2205
3628
77
3608
230
494
128
848
801
1335
4079
3059
636
2882
3524
45
1174
506
3570
4172
1289
595
3829
1532
179
1274
2574
1098
2817
226
2580
887
989
1829
3656
181
2056
3315
786
117
2519
2742
3787
1080
3138
686
1605
239
1533
2658
2096
753
3400
219
1815
117
1645
52
1671
121
2...

result:

ok 2519 tokens

Test #3:

score: 0
Accepted
time: 42ms
memory: 38204kb

input:

bbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbbbbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbbbbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbbbbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbbabbba...

output:

12
8
12
24
30
18
11
8
32
18
10
32
26
11
11
15
18
6
18
19
13
21
10
13
20
16
10
10
10
9
16
11
32
14
24
20
29
15
10
17
10
8
8
22
31
9
9
18
25
10
14
16
22
24
15
15
11
13
33
7
13
21
7
19
12
12
17
7
23
15
2
10
16
15
9
14
6
18
10
8
18
20
21
5
11
18
3
17
13
17
8
11
17
7
6
7
11
10
9
20
9
28
19
10
14
11
24
8
...

result:

ok 5000 tokens

Test #4:

score: 0
Accepted
time: 32ms
memory: 41384kb

input:

mkmamkmlmkmamkmnmkmamkmlmkmamkmamkmamkmlmkmamkmnmkmamkmlmkmamkmumkmamkmlmkmamkmnmkmamkmlmkmamkmamkmamkmlmkmamkmnmkmamkmlmkmamkmkmkmamkmlmkmamkmnmkmamkmlmkmamkmamkmamkmlmkmamkmnmkmamkmlmkmamkmumkmamkmlmkmamkmnmkmamkmlmkmamkmamkmamkmlmkmamkmnmkmamkmlmkmamkmpmkmamkmlmkmamkmnmkmamkmlmkmamkmamkmamkmlmkma...

output:

5
8
5
6
5
6
7
7
5
8
5
5
6
5
9
6
5
6
7
8
5
5
8
6
4
5
8
5
8
4
6
4
5
6
5
1
5
7
4
5
7
3
5
8
9
6
4
5
5
4
7
7
5
7
8
7
6
5
7
1
5
5
6
6
6
6
7
6
6
4
5
5
6
3
8
7
5
6
6
7
4
4
7
7
6
6
7
8
6
7
7
4
7
6
8
3
5
7
3
6
7
6
4
7
6
4
5
6
6
4
6
7
4
5
5
5
4
4
5
6
3
4
4
5
4
7
5
4
9
6
5
5
3
4
5
8
4
5
5
6
4
6
6
6
4
9
7
4
6
6
...

result:

ok 5000 tokens

Test #5:

score: 0
Accepted
time: 27ms
memory: 40644kb

input:

babababababababababababababababababababababababababababababababbbabababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababbbabababababababababababababababababababababababababababababababbbabababababababababababababababababababababa...

output:

58
13
6
23
52
35
39
46
17
43
37
33
31
8
51
12
9
52
57
14
28
17
31
21
59
50
55
50
18
10
54
7
44
11
10
3
12
19
9
8
5
7
22
4
38
15
10
14
26
11
21
18
33
12
3
8
23
34
41
18
7
18
26
7
12
29
34
6
4
15
16
20
15
8
50
23
7
51
18
4
11
7
20
14
33
19
12
9
10
6
8
21
28
22
21
18
12
18
4
15
17
13
8
16
7
14
10
4
5
3...

result:

ok 2443 tokens

Test #6:

score: 0
Accepted
time: 26ms
memory: 41452kb

input:

aaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaaaaaaaaaabaabaaaaaaaa...

output:

43
25
18
13
12
27
16
18
22
24
13
20
34
18
5
27
26
27
8
10
6
9
9
14
22
15
34
25
19
24
19
18
13
7
21
14
2
33
7
46
16
18
19
12
25
8
7
14
22
2
2
12
19
3
20
15
18
10
8
8
8
12
5
12
18
22
7
15
16
36
21
11
11
14
8
13
12
2
5
40
14
15
2
5
11
4
12
16
11
9
9
6
6
18
16
11
15
18
13
15
8
24
19
9
5
15
18
8
13
5
31
...

result:

ok 2498 tokens

Test #7:

score: 0
Accepted
time: 44ms
memory: 38416kb

input:

baabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabcaaaaaaaacbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba...

output:

67
7
4
13
81
3
8
92
28
86
94
92
71
23
73
26
24
13
71
88
98
42
70
45
82
63
5
80
57
49
48
77
88
5
98
96
65
52
11
24
52
51
76
90
9
10
58
43
36
48
82
73
10
14
90
54
74
12
32
36
71
46
8
46
20
38
22
68
54
73
66
32
95
63
52
7
40
97
27
13
42
59
41
14
9
44
53
52
92
30
36
27
86
90
59
95
12
36
42
16
24
58
23
5...

result:

ok 5000 tokens

Test #8:

score: 0
Accepted
time: 42ms
memory: 41708kb

input:

caaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaaccabccbaccaaccaaccaaccaaccaaccaac...

output:

10
10
11
11
11
10
10
10
8
10
11
11
9
9
10
10
10
11
10
11
9
10
10
11
11
11
10
11
11
11
11
11
11
11
11
10
10
10
10
11
11
11
10
11
10
10
10
11
10
10
10
10
10
11
11
11
11
10
11
11
11
10
11
11
11
10
10
7
11
11
10
11
10
10
11
10
11
10
10
7
11
11
10
10
11
11
10
10
2
11
11
11
5
11
11
11
11
11
10
10
10
11
11...

result:

ok 1667 tokens

Test #9:

score: 0
Accepted
time: 44ms
memory: 38224kb

input:

cabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbbaccbaccabccabbbbbb...

output:

38
38
38
37
38
38
38
9
37
38
8
38
37
38
38
38
38
38
38
37
27
38
38
38
38
38
38
30
38
38
38
38
38
38
38
38
24
38
38
38
38
38
38
38
38
38
37
38
5
38
32
25
38
38
38
38
38
38
38
38
38
38
38
37
38
37
38
31
38
38
38
38
38
38
12
38
38
37
38
38
38
38
37
38
38
38
23
38
38
38
38
24
38
38
38
38
38
35
38
38
38
...

result:

ok 1667 tokens

Test #10:

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

input:

baaabbbaaabbbbaaababbababbabbbbaaaababaababbbbababababbbaabbbaababaaaababbbaaabaaababbababaaabbabbbaaabbabbbabaabaaaababbbbabbbbbaabbabbaaaabaaabababbbaababbbaaaaaababbabaaabaaaabbbabbbaababbbbbbbbaabbbaabbabaabababbaabaabaabbbbbaaababbbbabbbababababaabbababaabbabbbbbbaaaaaaabaabbabbabaabbbbbaaaaaba...

output:

3
3
2
3

result:

ok 4 tokens

Test #11:

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

input:

abbaaabaabbbaabbabbbbbbaabbbbabbaabababaabbabbabaaabbabbbaaaabbabbaabbbabbbabbababaaaabbabbaabababbbaaababaababbabbaaabbbaabaaaaaabbbabbababaabbbbbabbbaaaaaaabbaaaabaaababbababaabaaabbbaaabbaabbabbabbbababbabbbbbbbbaabbabbbabbbbbbbababaabbbaabaabaabaaabababbaabbbbaaabbbbabbaabbbabbbababaababbabbabba...

output:

3
4
2
2
4
2
2
4
3
5
2
2
3
4
3
2
3
4
6
2
2
2
2
2
5
3
4
3
3
2
2
2
2
5
2
3
2
3
2
3
2
3
2
4
2
2
3
2
2
3
5
2
2
7
3
2
3
2
3
3
2
2
3
4
3
2
4
2
2
2
3
3
3
3
3
2
3
3
3
5
2
4
2
3
3
3
3
3
3
2
4
4
3
4
2
2
3
3
6
2
5
4
2
2
4
2
5
3
3
2
5
4
3
3
3
3
4
3
2
3
2
4
2
3
6
3
3
2
3
3
2
3
3
5
2
3
4
3
5
3
3
3
3
4
2
3
3
2
3
2
...

result:

ok 4997 tokens

Test #12:

score: 0
Accepted
time: 21ms
memory: 39888kb

input:

lxxhwqorbxrdzedxlvymggyicczuafgyovixrzmptqfmjyjfpamcsehmfazbvfwdgeftgbtyurnnykwjhzfqqsyiyzkpwlmspjsxdkjtpgzbrvwwcjqejmuillhgtbhwtwmvhacfphrcgwoaihjzkuccmwuidivmpjcezbjywhbqtdgrhlrskcwmecflzpjbuutlocivcfvbcdvlnfchtvvcpoubnjwfwvzvpyvhkvxdmleyvucrondntpaonjybzarkgjnkuuvipkqgvwzzzopwyfnmodnmdziueescfttr...

output:

1
1
1
1
1
2
1
1
1
1
1
1
2
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
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2493 tokens

Test #13:

score: 0
Accepted
time: 104ms
memory: 39884kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

849
1135
1444
1346
1445
536
3077
2631
1447
672
2214
2149
2090
4054
846
559
22
92
4224
161
2280
572
2347
2599
778
4093
750
3647
2142
642
474
1395
776
645
46
4141
2272
771
1564
207
4284
2896
3097
2829
306
1383
394
1776
1284
3933
102
510
1101
3639
1336
1292
2803
1159
601
1464
2585
673
281
1340
272
3310...

result:

ok 2478 tokens

Test #14:

score: 0
Accepted
time: 352ms
memory: 39904kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
5000
...

result:

ok 4999 tokens

Subtask #2:

score: 0
Time Limit Exceeded

Test #15:

score: 10
Accepted
time: 3878ms
memory: 68128kb

input:

aabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbbaaabbaabbbbaabbaaabbbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabbababaabbaaabaaaaaabaaabbaabababbabbbbbbabbababaaaabababbabbbbbbabbababaaaabababbabbbbbbabb...

output:

41
43
154
118
55
165
48
163
119
207
147
145
33
67
114
124
154
9
104
307
102
73
39
364
79
177
53
39
88
264
77
114
79
195
150
153
157
46
129
136
147
25
309
11
12
258
259
133
355
50
116
336
13
127
18
34
122
161
38
99
290
92
355
166
59
152
41
182
103
282
166
23
86
173
32
122
60
127
287
20
83
214
119
144...

result:

ok 200000 tokens

Test #16:

score: 0
Accepted
time: 3675ms
memory: 69008kb

input:

beebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebccbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeebbeebbeebbeebbeebddbeebbeebbeebbeebbeebbeeb...

output:

38
55
18
35
62
44
48
20
70
35
36
42
40
11
14
13
67
54
61
70
51
27
62
18
39
52
53
53
34
57
53
46
28
22
15
64
32
44
11
11
57
35
21
45
32
39
42
27
31
51
28
31
18
12
25
41
55
37
42
17
38
33
21
29
54
15
43
24
17
42
63
19
32
49
17
21
50
62
52
56
49
56
18
24
17
22
26
18
60
31
24
59
58
69
18
16
38
39
54
48
...

result:

ok 200000 tokens

Test #17:

score: 0
Accepted
time: 3198ms
memory: 68360kb

input:

cgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagcaidiaaidiacgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccgaaaabgceiddiecgbaaaagccg...

output:

17
15
19
21
17
18
21
12
12
15
18
20
14
14
16
20
15
19
11
17
10
20
16
16
16
19
12
17
16
15
18
12
24
20
12
19
9
17
13
21
28
10
13
17
10
14
13
24
17
17
19
24
11
18
16
14
13
13
17
13
22
21
20
14
7
11
18
15
18
12
12
12
19
14
15
16
19
20
16
23
19
16
18
13
24
22
17
13
15
21
21
22
13
21
19
20
9
20
14
14
15
...

result:

ok 200000 tokens

Test #18:

score: 0
Accepted
time: 2523ms
memory: 68700kb

input:

rprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprwrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprvrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprwrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprxrprkrprxrprmrprxrprbrprxrprmrprxrprkrprxrprmrprxrprhrprxrprmrprx...

output:

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

result:

ok 200000 tokens

Test #19:

score: -10
Time Limit Exceeded

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998
199998...

result:


Subtask #3:

score: 10
Accepted

Test #21:

score: 10
Accepted
time: 2045ms
memory: 68356kb

input:

abbaaaabbabaaaaaabaabbaabbababbaaabbabbbabaabaabaaaaabaabbbbabbabbabbbababbbababababbbbabaabbaaababbbbbababbbbaabbbaaabaababababaabbbbbbaababaabbaaabaabbaaababbabbabbbbaaaaabaaabbbabbbbbbabbbabbabaabbbbbbbaaaabbaaaababbbaaaaaaababaabbbbaaabaaabbaabbbbbbababbaabbaaabbabbbbbabaababbaabaaaabbbbabababba...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
8
8
8
8
...

result:

ok 198 tokens

Test #22:

score: 0
Accepted
time: 1522ms
memory: 69108kb

input:

abbaababbabababbbbabababbbaaaabababbbbaabaabbbbabbbabbaabababbbabaaabbabbaabbbbbbaaababaababbbaabbbbaabbbaaaaaabaabbaabbaaaabaaabbaabbbaabbbababbbabbaaababaabaaabaabbabababaaaabaabbbbaaabbbbbbabbbbababbaabaabbbbabbaaabbaabaabbaabaabaaaaaabbaaabbbbbabbbbbaaabbabbabbaababaaabbabbaaaaaabbababbbaabbaabb...

output:

2
6
2
2
3
2
2
3
4
3
4
3
2
8
2
3
2
4
4
4
3
2
4
3
4
4
2
3
3
3
3
2
13
4
2
5
5
3
3
2
2
4
2
3
3
4
3
2
2
3
3
2
2
6
3
4
3
3
2
2
2
3
2
3
3
4
3
2
2
3
2
4
3
5
5
3
3
2
2
3
3
2
3
4
5
2
2
3
2
5
3
2
5
3
5
3
3
2
5
3
3
4
4
2
2
3
4
2
2
2
2
3
3
2
2
5
3
2
3
3
4
2
6
3
2
13
2
2
2
3
2
2
4
2
3
2
3
3
4
4
5
4
3
2
12
2
2
3
2...

result:

ok 199806 tokens

Test #23:

score: 0
Accepted
time: 1919ms
memory: 68888kb

input:

bbabbbaaaaabbbbabaabbaabbaabbbaabbabaaabaaabbbbabbbabaabbbbbbbabbbaabbbabbabaabababaaababaabaaabaabbbabbbbbabbbbbbbbbbbaaabaaaaabaaaaababbaaaaabbabaaabbabaabababaabbbabbbbaabaabbaaabaabbaabbbbbababbabaabbbbaaabaaaababbabbaaaabbabaabbabbbbbababbabbbaaabababbababbbaabbbbabbbbaaabbabbaaabbaaababbabaaab...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 199800 tokens

Test #24:

score: 0
Accepted
time: 1591ms
memory: 68544kb

input:

bababaaaaabbabbbbababbbbbbababbbbbaaaabbabbbbabaaababbababbaaabbabababbabbaabbabbbaababbbabaaaabbabbababbabbbabababbabbaabbbaabaabaabbbaabbabbabbababbabbaaabbbabababababaababaababbbaaababbbaababbbbabaaabaaabbababaaabbbbbaabababbbbbaabaaaaababaaabaababbaaababbbbabbbbbaababbababbbbabaabbabbbabaaaabbbb...

output:

3
2
2
2
4
2
2
4
2
3
2
4
4
2
3
2
2
2
3
3
3
3
3
2
4
5
4
2
3
2
3
2
3
2
2
3
3
3
3
3
3
3
2
3
2
3
3
3
2
4
3
3
2
2
3
5
2
3
3
3
3
2
4
4
3
2
2
2
7
3
3
2
4
2
5
5
4
3
2
4
2
2
2
2
3
4
2
6
5
3
2
4
3
3
3
3
5
3
4
2
2
2
2
2
3
2
3
3
4
5
3
2
2
2
2
3
5
2
4
2
3
2
5
3
2
3
2
3
3
2
3
2
2
2
3
2
2
2
3
3
4
2
4
4
3
5
5
3
4
2
...

result:

ok 199800 tokens

Test #25:

score: 0
Accepted
time: 2108ms
memory: 68876kb

input:

aaabaaababbbabaaaababbbaabaaaabababaaabbaaaabbbbbabbaabbbbbbabbabbbaabaaaabbbabbbbbbbbaabbaaaaaabbabbaabbaaaaaabaaaabbbbbbaabbaabaaabbbaaaaaaabbbabaaaaabbbabbbaaabaaaabababaaaaaaabaaabaababbbbabbbabbbaabbbbaaaabbbbaababaababaaabbaabbbaabbabaabaaabbabaaababbaaaaabaaaabbbbabaaabbbaaaaabababbabaabbabab...

output:

3
2
3
3
2
2
3
3
2
4
2
4
3
4
3
2
3
2
2
4
2
2
2
3
2
3
2
2
2
3
4
4
3
2
2
6
2
4
3
4
4
3
2
2
5
2
2
3
4
3
3
3
7
4
3
4
3
2
4
4
4
4
3
3
3
2
2
2
3
3
2
3
6
2
2
3
3
2
2
2
2
2
2
3
2
3
2
5
4
3
3
3
2
3
3
4
2
2
4
4
2
3
3
2
6
3
2
3
4
3
2
3
3
2
3
2
2
3
4
3
4
3
2
3
3
2
2
2
3
5
2
3
3
3
2
2
2
4
2
2
4
3
2
2
3
3
3
2
2
2
...

result:

ok 211 tokens

Test #26:

score: 0
Accepted
time: 1449ms
memory: 68492kb

input:

ababaaabaabbbaabbaabaaaabaaabaabbababbababaabbaabbbbaaabaabaabaaaabaababbbaabbabbaaabaabbaabababbbababbabaaaabbabbbbbbaabababbbbababbaaabaaababbbbaabbaaaabbbbaaabbbabbabbaabbbbababbaabaabbabbababbabbaababbbaaaaababbaabbbbabaabbbabbbbbaaababbaaabbbbaaababbaababaaabaaabaababbabaabaabbbbaaaaabbababaaab...

output:

3
2
2
3
3
5
3
4
3
3
2
3
4
2
3
4
3
3
3
2
3
4
2
4
2
3
2
2
2
3
3
4
3
2
3
3
4
4
3
2
3
3
3
2
3
2
3
3
5
2
2
2
4
3
3
2
2
2
5
4
3
7
2
3
2
5
3
2
3
3
3
3
3
2
2
4
3
3
2
2
2
2
3
2
7
3
2
3
3
2
2
3
2
2
3
3
4
3
4
3
4
3
2
2
3
3
3
4
3
5
5
2
2
3
4
5
3
3
5
3
2
2
3
2
8
3
5
5
3
3
2
3
4
2
2
4
2
2
2
2
2
4
4
3
4
3
3
2
3
2
...

result:

ok 199782 tokens

Subtask #4:

score: 0
Time Limit Exceeded

Test #27:

score: 10
Accepted
time: 1069ms
memory: 68944kb

input:

babbaaabbbbbbbabbbababaabbbbbababababbaabaabbbbbbabbbbbbbbbbababbbbabbaabbbaabaabbabbbaabbabbbabbababaababbbabbbbaabbabbabbaaaabbbaaabbbbaabbaaaaaaabbbabbbaaabaababaaabaaaabaaaababaaaaababaaaabaabbaaaabbbabbaabaabbbabbbbbaaabaababbbaaaaabbbbaaabbbbaabbabbbbabbbabbaaaaabaabaaaabbbabbbbbaabbbbabbbbaab...

output:

4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

ok 100490 tokens

Test #28:

score: 0
Accepted
time: 1833ms
memory: 68840kb

input:

lqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqlfibyjjybiflqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqlewwelqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvdqllqdvhpozemuhtibmunxftkdjjdktfxnumbithumezophvd...

output:

487
218
218
140
154
154
148
148
64
64
334
160
7
7
7
7
7
7
7
101
101
91
91
6
6
442
143
429
121
113
113
54
33
33
33
33
172
172
149
33
33
33
33
33
33
33
355
355
355
338
272
272
57
57
57
57
29
29
29
29
29
109
109
9
9
9
9
9
9
9
238
238
238
238
163
163
163
194
194
186
186
83
83
406
266
79
79
79
79
79
79
7...

result:

ok 66667 tokens

Test #29:

score: 0
Accepted
time: 1713ms
memory: 68292kb

input:

vbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvwwxxlwqetrlgyolqqloyglrteqwlxxwwvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvwwxxlwqetrlgyolqqloyglrteqwlxxwwvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzaxhgbvvbghxazviovddvoivzax...

output:

13
8
13
5
5
5
13
12
5
5
5
5
5
5
5
5
12
12
12
12
12
12
12
13
9
9
5
13
13
12
12
12
12
12
12
13
13
13
13
13
12
12
12
13
13
13
13
13
12
12
12
12
12
13
5
5
13
13
13
13
13
13
13
12
12
12
12
11
6
6
13
5
13
13
13
13
11
11
11
11
8
8
8
8
8
8
8
13
13
13
13
13
5
5
5
5
5
13
12
12
9
9
9
9
9
9
9
12
12
12
12
12
12
...

result:

ok 66667 tokens

Test #30:

score: -10
Time Limit Exceeded

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000
200000...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #35:

score: 0
Time Limit Exceeded

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

199105
199317
198628
198977
198643
198338
198952
198567
198980
198350
199045
199831
199124
199126
199123
199367
198992
198131
198623
199391
199376
199431
198418
198674
199222
199031
198833
198400
199208
198925
198477
198700
198952
199129
199580
199549
198972
199285
199185
198739
199281
199208
198920...

result:


Subtask #6:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%