QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#538099#5084. Longest SubstringTiga_Pilot_2TL 96ms9284kbC++205.3kb2024-08-31 00:06:272024-08-31 00:06:27

Judging History

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

  • [2024-08-31 00:06:27]
  • 评测
  • 测评结果:TL
  • 用时:96ms
  • 内存:9284kb
  • [2024-08-31 00:06:27]
  • 提交

answer

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

#define fi first
#define se second
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge {c b, e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
    ~debug() {cerr << endl;}
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair <b, c> d) {
        ris <<"(" <<d.fi <<", " <<d.se <<")";
    }
    sim dor(rge<c> d) {
        *this << "[";
        for(auto it=d.b;it!=d.e;++it) {
            *this <<", " + 2*(it==d.b) <<*it;
        }
        ris << "]";
    }
};
#define imie(...) "[" <<#__VA_ARGS__ ": " << (__VA_ARGS__) <<"]"

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i > (b); --i)
#define ar array
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
typedef vector<int> vi;
#define all(x) (x).begin(), (x).end()

template<typename T>
void min_self(T& A, T B) {
    A = min(A,B);
}
template<typename T>
void max_self(T& A, T B) {
    A = max(A,B);
}

const int mxn=5e4;
int n;
string s;

struct SuffixArray {
    vi sa, lcp;
    SuffixArray(string& s, int lim=256) { // or basic_string<int>
        int n = sz(s) + 1, k = 0, a, b;
        vi x(all(s)+1), y(n), ws(max(n, lim)), rank(n);
        sa = lcp = y, iota(all(sa), 0);
        for (int j = 0, p = 0; p < n; j = max(1, j * 2), lim = p) {
            p = j, iota(all(y), n - j);
            rep(i,0,n) if (sa[i] >= j) y[p++] = sa[i] - j;
            fill(all(ws), 0);
            rep(i,0,n) ws[x[i]]++;
            rep(i,1,lim) ws[i] += ws[i - 1];
            for (int i = n; i--;) sa[--ws[x[y[i]]]] = y[i];
            swap(x, y), p = 1, x[sa[0]] = 0;
            rep(i,1,n) a = sa[i - 1], b = sa[i], x[b] =
                (y[a] == y[b] && y[a + j] == y[b + j]) ? p - 1 : p++;
        }
        rep(i,1,n) rank[sa[i]] = i;
        for (int i = 0, j; i < n - 1; lcp[rank[i++]] = k)
            for (k && k--, j = sa[rank[i] - 1];
                    s[i + k] == s[j + k]; k++);
    }
};

template<class T>
struct RMQ {
    vector<vector<T>> jmp;
    RMQ(const vector<T>& V) : jmp(1, V) {
        for (int pw = 1, k = 1; pw * 2 <= sz(V); pw *= 2, ++k) {
            jmp.emplace_back(sz(V) - pw * 2 + 1);
            rep(j,0,sz(jmp[k]))
                jmp[k][j] = min(jmp[k - 1][j], jmp[k - 1][j + pw]);
        }
    }
    T query(int a, int b) {
        assert(a < b); // or return inf if a == b
        int dep = 31 - __builtin_clz(b - a);
        return min(jmp[dep][a], jmp[dep][b - (1 << dep)]);
    }
};

void solve() {
    cin >>s;
    n = sz(s);
    SuffixArray sa(s);
    RMQ<int> rmq(sa.lcp);
    vector<pii> ans(n,{0,0});
    ans[0] = {1,n};
    set<int> st;
    int la=-1,ra=-1;
    auto eval = [&](int lenj) -> pii {
        int notoverlap = 0;
        int r = -1;
        while(true) {
            auto it = st.upper_bound(r);
            if(it==st.end()) {
                break;
            } else {
                notoverlap++;
                r = (*it)+lenj-1;
            }
        }
        return {notoverlap,lenj};
    };
    rep(i,1,n) {
        int start = sa.sa[i];
        if(ra<i) {
            la = i, ra=i;
            st.clear();
            st.insert(start);
        }
        // int len = n-start;
        rep(lenj,sa.lcp[i]+1,sa.lcp[i+1]+1) {
            int ri = i+1;
            int l=i+1, r=n;
            while(l<=r) {
                int mid = (l+r)/2;
                int qry = rmq.query(i+1,mid+1);
                if(qry>=lenj) {
                    ri = mid;
                    l = mid+1;
                } else {
                    r = mid-1;
                }
            }
            int k = ri-i+1;
            if(ra<=ri) {
                // debug() <<"1";
                rep(j,ra+1,ri+1) {
                    st.insert(sa.sa[j]);
                }                
                ra = ri;
            } else if(ra-ri < ri-la+1) {
                // debug() <<"2";
                // debug() <<imie(la) imie(ri);
                per(j,ra,ri) {
                    st.erase(sa.sa[j]);
                }
                ra = ri;
            } else {
                // debug() <<"3";
                st.clear();
                rep(j,la,ri+1) {
                    st.insert(sa.sa[j]);
                }
                ra = ri;
            }
            // debug() <<imie(la) imie(ra) imie(sz(st));
            // if(ra-la+1!=sz(st)) {
            //     debug() <<imie(la) imie(ra) imie(sz(st));
            //     assert(false);
            // }
            // assert(ra-la+1 == sz(st));
            max_self(ans[k-1], eval(lenj));
        }
        st.erase(start);
        la++;
    }
    rep(i,0,n) {
        cout <<ans[i].se <<" \n"[i==n-1];
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

ababa

output:

5 2 1 0 0

result:

ok single line: '5 2 1 0 0'

Test #2:

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

input:

aaaaaaaa

output:

8 7 6 5 4 3 2 1

result:

ok single line: '8 7 6 5 4 3 2 1'

Test #3:

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

input:

a

output:

1

result:

ok single line: '1'

Test #4:

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

input:

abcdefghijklmnopqrstuvwxyz

output:

26 0 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 single line: '26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #5:

score: 0
Accepted
time: 76ms
memory: 9248kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

50000 49999 49998 49997 49996 49995 49994 49993 49992 49991 49990 49989 49988 49987 49986 49985 49984 49983 49982 49981 49980 49979 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49962 49961 49960 49959 49958 49957 49956 49955 49954 49953 49952 49951 ...

result:

ok single line: '50000 49999 49998 49997 49996 ...4 13 12 11 10 9 8 7 6 5 4 3 2 1'

Test #6:

score: 0
Accepted
time: 86ms
memory: 8088kb

input:

abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab...

output:

50000 49998 49996 49994 49992 49990 49988 49986 49984 49982 49980 49978 49976 49974 49972 49970 49968 49966 49964 49962 49960 49958 49956 49954 49952 49950 49948 49946 49944 49942 49940 49938 49936 49934 49932 49930 49928 49926 49924 49922 49920 49918 49916 49914 49912 49910 49908 49906 49904 49902 ...

result:

ok single line: '50000 49998 49996 49994 49992 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #7:

score: 0
Accepted
time: 12ms
memory: 5840kb

input:

hnpyezhavuychdbjldxjofydbuekupcjllbrtehyfangipyjjqhivkyhnlrotjgftqhwlpvmsjtikgsspaxswleauvtzbmqjdywpnilqhawmcqprtynqylzbjganroyiwcbiyqklolxabdowwkrxhzuahgjabvvrkdelzvtdsavbipxpddsopnnxjwasoxnpgknyxrcuypmbgvgymrlymkcufnptcdwbpihxhayfqoylfvrgzhhferphxfjruejyztauvklpchuxduvosjrbwqvnofdnzhtkvwwbdenlzkyf...

output:

30918 6 4 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 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 0 2 2 0 2 2 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '30918 6 4 3 3 3 3 3 0 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #8:

score: 0
Accepted
time: 11ms
memory: 5996kb

input:

ujwgcpuvylongozaczorldxrlmgmdyxenplvanjgtgfgzdvllphwyuqvjmzvfskbmjndeazlljvcjwpgmbmhhnlppoahzjxzhlastuawhchrbajvfxgpxgrrzjjnufizgrofjnegdgrdsxnepoajtppsqpsjvscmekdwbsfecczcittiirastwwmhzrtjwksdlwchghosqslgniyxkvoukvbqhmfegaxrljefutidcelusbenpvuzwizoiznksyejikaovbngxmzzjrrumgdkvczjftegspfutgyayaxfozq...

output:

36879 5 4 3 3 3 3 3 3 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 2 0 0 2 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '36879 5 4 3 3 3 3 3 3 0 3 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #9:

score: 0
Accepted
time: 13ms
memory: 5552kb

input:

jrjefrpmcidljqjqbgcezgstiefshrvwcmtciarsnrnuucovzlltwvbmorxkwlrquidxnvejjedkendyssdtulgavoninkvcjzcpxsnnofaprgfclhxuezkbsezoefqgnnyxbvutgazsjttfftpjturngqoxpisvkpvkgypdpdwittmxnaaorxdkrldlrtatxwheabbyrezemqvymwzqffpysmqicopqxmsydemwzzalmjmjaewqqxwribmpfkafjmgsrpeimoulryfmmrxbvrhxatwoqrtaxqgboohpyqoe...

output:

32956 6 4 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 2 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '32956 6 4 3 3 3 3 3 3 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #10:

score: 0
Accepted
time: 15ms
memory: 5980kb

input:

bqxywpdcsnccafvrbhsoffpezhdlywtbqpnqfkibmmvsacuohwzsrfmbvqhnqhhnvbkpzrofxssllygtwhxmbtxhvrnivshojgahurbgsnyvxgfdyzgqldgrbnutsakmruxlaadlqqiucwoumrhbkwdosgujwarnmgsjmsexfchydumtjapmngxzyxomsqqfxiksydtjvjnlimzjjeewbjmawzoqmkloamspatyraxnjdkncradykxajsqdbsbairguqqsaixggzrpavkporwnlbukavfsnzqsrxrjokttkn...

output:

37924 6 4 3 3 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 2 0 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 0 2 2 2 0 2 2 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok single line: '37924 6 4 3 3 3 3 3 3 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #11:

score: 0
Accepted
time: 8ms
memory: 5200kb

input:

bpgokflgellqalcfmnkaazoyenqztpllksopthmvpkmdgmjuhsdmawvgnxomrjpolstdymwkkjpxwxqeltezasdzatufflpyqrgtrkccierbjnrlguvpvyfrgvguivfdpcoankfoooewwulzzmbnltuysvvbethgnvdwpeusklobltcwvubybjtknhzpappqihgnziujksebunfncqgbqylpszscsvhuwmextkqlbxjktubotyzmhklohbesxujsduwreuayrhbsmsbimdlnzxllygzazsavtdejpdkhonch...

output:

21337 6 4 3 3 3 3 3 0 0 0 0 0 0 2 2 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '21337 6 4 3 3 3 3 3 0 0 0 0 0 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #12:

score: 0
Accepted
time: 94ms
memory: 8124kb

input:

baaaabbababbabbaabbbabaabbababbbbababaaaabbbabaabaabaababbabaabbabaaaababbbbbaaabaaabbabaaabbbabbaababbbbabbbbabbabbbaabbaababbaabbabababbbbbbbabbaaaababbababbbbabbbaabbabbabaabaaaaaaababaaaaabbbbbabbaaaaabbabbbaabbbaabbabababbbaabbaaabaaaabaabaabaabaabbbbbbaabaabbaaaaaabababaabaabbaaaaababbbbbbbbba...

output:

50000 30 22 19 18 17 16 15 14 14 14 14 13 13 13 13 13 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 9 9 0 9 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

result:

ok single line: '50000 30 22 19 18 17 16 15 14 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #13:

score: 0
Accepted
time: 93ms
memory: 7932kb

input:

aaabbabbabaaabbaaabaaaababbaaaaaabbbabbabbbbbaababbbabbaaaaaabaaabbabbbabbaabbbabbbbaabababbbabbbabbbabaababbaaaabaaabbbaaabbbbaaabaaaabaabaaabbaabababaabaaabbabbabbababbbbbababbaaaaabababbaaababbbaabbabbaabbbaaabbbaabbabbbaaabbaabbbbbaaaabbaabbbaabbbaaaababbbbaabaabbabbabbabbbabbaaabbbabababbbababa...

output:

50000 28 24 20 19 17 16 16 15 14 14 13 13 13 13 13 13 13 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 10 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 9 0 9 9 10 0 9 0 9 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

result:

ok single line: '50000 28 24 20 19 17 16 16 15 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #14:

score: 0
Accepted
time: 96ms
memory: 8084kb

input:

bbbbbbbabaaaaabaaaaabaaabaabaaabbbabbbbabaabaabaaaabbbabbbbbabbbaabababbabbbabaaabbbabbbababbabaabaaabbbabbbabaabbabbababbbbbbaaabbbbbbabbbbaabaaaaabbbabbbbbabbabaaaaaaaabaaabbbbbababbaaabaabbabaaabbbabaabaaaaaabababbabbbabbaabaaaaabaabbaabaabaabaabbbbabbababbbaaabbaaaaabaababbbaabbaaabbabaaaaabaabb...

output:

50000 33 20 18 17 16 16 15 14 14 14 14 13 13 13 13 12 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 11 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 10 9 0 9 0 10 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9...

result:

ok single line: '50000 33 20 18 17 16 16 15 14 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #15:

score: 0
Accepted
time: 93ms
memory: 7852kb

input:

abaaabbbbaabaaabbabbbbabababbaabbabbbabbbabbaabbbbabbbbbaabbabaaabaabaababbaaaaabbbbababbaaabaaaaabbaabbaaababababbbaabaaabbaaaabbbababaabbaababbbaaabbbbbbabaababbbbabbbbbabbaabbbbaaabaaabaabbaaaabaaaabbababbbababbaaabbabbbbababbbbaabbbbbaaabaabababbbaaaabbbabbabbabababbabaabaabbaabababbaabababbbaba...

output:

50000 28 21 19 18 17 16 15 15 14 14 14 14 13 13 13 13 13 12 13 12 12 12 12 12 12 11 12 11 12 11 11 11 11 11 11 11 11 11 11 11 11 10 10 10 10 10 10 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 10 10 0 10 10 9 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

result:

ok single line: '50000 28 21 19 18 17 16 15 15 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #16:

score: 0
Accepted
time: 90ms
memory: 8012kb

input:

baabababbbbbbabbbbbbbbbbabaabbbaaaabaaabbabaabbaaababaabbbaabababababbbaababbaabbabbbababbabbaabababbaabaaaaaaaabbabaabbbbabababbbaaaaaabbaabbbabbabbabbaabbabbababaaabaaaaabaabbabaababbbabbabaaaaaaaaabbbaaabbaaabbbbaabbbaabbaaaaaaababaaabbbbaabbbabbaabbbbaaaabbababaaaababbabaaaabbaabababaaaababbbaba...

output:

50000 29 22 18 17 16 15 15 14 14 14 13 13 13 13 13 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 9 10 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

result:

ok single line: '50000 29 22 18 17 16 15 15 14 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #17:

score: 0
Accepted
time: 62ms
memory: 7588kb

input:

wvwwwuuvwwwuuwvwuwwwuvuuuvwuwuwuwuvuuvwvvvuuvuwuvvuvvuuuwuvvwwvwwvwvvwwvvuvwuuvuuuwuuwvvuuuwvuwwwvwvvuuuwuuuwvwuuwuwwvvwvwvwvwwvwvuvuwvvwuuwvwvvvwvwwuwwvvvvvuwuuwwwuwuuvvvvuwwuuuwuwwuvvvvwwvuwvwuvuuuvuwvuwuvvwwwuuwwvwwuwvvuvuuvwuwvuuuwuuwuuvuwuuwuvuuwuwvuvwuvwwvwuuuvuuwvuwuuuwwuuuuuvvvvuvwwwwvuvuuwv...

output:

50000 23 14 12 11 10 10 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 0 0 6 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 6 6 0 0 0 6 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '50000 23 14 12 11 10 10 9 9 9 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #18:

score: 0
Accepted
time: 58ms
memory: 7584kb

input:

qrqqqqqrrrrrrpprqprrpqprprrppqpqqrpprqrrppqqqrqpqpqprrprqpqprqqqqqrrrrpqrpqqqrppppqqrrrqpqprprqqqpqqqqprpprqqqppqpppprppqpppppprqqprrqrprrqqpqrqrqprqpprpqqppprqqpprqrqprqrqqrqqqrprqpqpqpprpqqqqpqqqqqpqqqppqqqqqrqprqprrprprprprpppqqqqpqppqqqprqrqqrqrqrrrpprrrrrqrprrpqpqrrrrrqrqpppqrprppqqrrpqqqrprrrp...

output:

50000 18 13 12 11 10 9 9 9 9 9 8 9 8 8 8 8 8 7 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 0 0 0 6 0 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 6 6 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '50000 18 13 12 11 10 9 9 9 9 9...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #19:

score: 0
Accepted
time: 63ms
memory: 7664kb

input:

opoqoqpqopqpqppqoooqoqpqpooppqppqooqoqpooqpqopqpoqqqqqqqqqpqoqqoooqpqpoqqoopoopoqpqppqoqoqoopopopqpoooppoqppqoooqqoooppqqopqopoqqqpqoqqopoqpopopqqpqppqqqpqpqqpqqoqooppqqpoopqqqqqpoppqoqqpqqqqopqqoqqpoppoopqpqoppooppqpqoqqppqqoooooopqqooqpppoopqqpppoooppqoopqoopopqqoopoqooppppooqqqoqqpooqqqqqqqqoooqp...

output:

50000 19 13 12 11 10 10 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 6 0 0 0 0 6 6 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 6 6 6 6 6 0 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '50000 19 13 12 11 10 10 9 9 9 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #20:

score: 0
Accepted
time: 58ms
memory: 7740kb

input:

opqoqppqqqqoqopqoqqqpqpqpqoqooopqpoqqqpopqqooppooppooopooooppppqpoqqqoqpoooppqqpooopoqpoppqooqpoooqppoopqpqqooooqooqqqoqqoqqqqopooooqqpqqooqppopooopoopopqpqqqqoqppqopqpqoqoooooqpqooqqqoopoopopqqqqoqqqpppoopqqqqoopoqqqooqoqqppppoppppqooqoppqoopqqppopqqoqppoppooopqpqpopqqoqoopoqqqqooqppoqqpoooqqqqooqq...

output:

50000 19 13 12 11 10 9 9 9 9 9 8 9 8 8 8 8 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 6 0 0 6 0 6 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 0 6 6 0 0 6 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 single line: '50000 19 13 12 11 10 9 9 9 9 9...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #21:

score: 0
Accepted
time: 89ms
memory: 7952kb

input:

qrqqqrqrrqrrqqqqqqrrrqqrqrrrqqrrqqqqrqrqqrqrrqrrrrqrqrrrrqqrqqqqrrrrqqrrrrrqrrqqrqqqqqrqrqrqrqrqqrrrqrrrrrrqrrrrqqrqrqrqqqqqrrrrqqrrqqqrrrqrqrqqqqrrqrqqqrqqqqrrrqqqqqqqqqqrqrrrrqrrqqrrrrqrqqqrqqqrrqqrqqrrqqqrrrqqqrrrqqrrqqqrrqqqqqrqqqrrrrrqrrqrqrrrqrqqqrrqqqqrrrrqqrqrqqrqqrqqqqqqqrrqrrqrrqrrqrrrqrqr...

output:

50000 28 21 18 17 16 15 15 14 14 14 13 13 13 13 13 12 12 12 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 0 0 10 10 9 9 9 9 0 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...

result:

ok single line: '50000 28 21 18 17 16 15 15 14 ...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'

Test #22:

score: 0
Accepted
time: 61ms
memory: 9284kb

input:

dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

50000 15040 15039 15038 15037 15036 15035 15034 15033 15032 15031 15030 15029 15028 15027 15026 15025 15024 15023 15022 15021 15020 15019 15018 15017 15016 15015 15014 15013 15012 15011 15010 15009 15008 15007 15006 15005 15004 15003 15002 15001 15000 14999 14998 14997 14996 14995 14994 14993 14992 ...

result:

ok single line: '50000 15040 15039 15038 15037 ...0 3 0 0 0 0 2 0 0 0 0 1 0 0 0 0'

Test #23:

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

input:

cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

50000 10373 10372 10371 10370 10369 10368 10367 10366 10365 10364 10363 10362 10361 10360 10359 10358 10357 10356 10355 10354 10353 10352 10351 10350 10349 10348 10347 10346 10345 10344 10343 10342 10341 10340 10339 10338 10337 10336 10335 10334 10333 10332 10331 10330 10329 10328 10327 10326 10325 ...

result:

ok single line: '50000 10373 10372 10371 10370 ...2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0'

Test #24:

score: -100
Time Limit Exceeded

input:

hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...

output:


result: