|
|
вернуться в форумWRONG answer 5 #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 |
|
|