ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1723. Sandro's Book

WRONG answer 5
Posted by jakhongir 12 Oct 2016 23:41
#include <bits/stdc++.h>
using namespace std;
const int N = 112345;
int a[N];
int b[N];

main()
{
    string s, t;
    cin >> s;
    int cnt = 0;
    int mx=0;
    int l=0;
int cnte=0;
    for(int i = s.size() - 1; i >= 0; i --)
    {
        t = s[i] + t;
        a[0] = 0;

        for(int j = 1; j < t.size(); j ++)
        {
            int x = a[j - 1];
            while(x > 0 && t[x] != t[j])
                x = a[x - 1];
            if(t[x] == t[j])
                x ++;
            a[j] = x;
            mx = max(mx, a[j]);

        }
            b[i]=mx;
            if(mx==0)cnte++;
            mx=0;

    }
    if(cnte==s.size()){cout<<s;return 0;}
    else
for(int i=0;i<s.size();i++){if(b[i]>=1)cout<<s[i];}


}
// any suggestion guys I have no idea what can be  the fifth test thanks in advance