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 1297. Palindrome

SEE THIS SOLUTON! I LIKE IT!
Posted by Gerasim Petrov Velchev 9 Aug 2008 16:04
#include "iostream"
#include "string"
#include "vector"
using namespace std;
bool is_palindrom (string s,int nach,int krai) {
for (int i=nach,j=krai;i<=j;i++,j--) if (s[i]!=s[j]) return false;
return true;
}
int main () {
char ch;
string s,s1,spal;
int j=-1,mx=-1;
while (cin>>ch) {
s+=ch;
j++;
int i=-1;
string s1=s;
vector<int>a;
do {
    i++;
    if (s1[i]==ch) a.push_back(i);
}
while (i<=s1.length());
for (int i=0;i<a.size();i++)
    if (is_palindrom(s1,a[i],j)) {
                              string s2=s1.substr(a[i],j-a[i]+1);
                              int l=s2.length();
                              if (l>mx) {mx=l;spal=s2;break;}
                              }
}
cout<<spal<<endl;
system ("pause");
return 0;
}
Re: SEE THIS SOLUTON! I LIKE IT!
Posted by AlMag 9 Aug 2008 20:09
Why're u doing this?
For Author!
Posted by Pavel Khaustov [Tomsk PU] 10 Aug 2008 00:26
Stop posting your own solutions! Admins will add you to ban list (see rules of behavior for this web-site)... And try to solve something interesting and really hard...

Edited by author 10.08.2008 00:26