|
|
вернуться в форумcub(N) Solution Послано aybek 13 фев 2013 14:42 I don't know why this solution is correct, but it got accepted. I thought that this solution will get TL. Author of problem: easy tests? Who couldn't find solution try to understand this code: #include<map> #include<cmath> #include<ctime> #include<vector> #include<cstdio> #include<string> #include<cstring> #include<cstdlib> #include<iostream> #include<string.h> //#include<windows.h> #include<algorithm> #define y1 abcde #define sqr(x) ((x)*(x)) #define INF 20000000000000000 using namespace std; string s; int i,n,ans,j,l,r;
bool check(int l,int r) { for(int i = 0; i < (r - l + 1) / 2; i++) if (s[l+i] != s[r-i]) return false; return true; } int main() { //srand(GetTickCount()); #ifndef ONLINE_JUDGE freopen("a.in","r",stdin); freopen("a.out","w",stdout); #endif cin>>s; n = s.size(); i++; s = '#' + s; for(i = 1; i <= n; i++) for(j = i; j <= n; j++) { if (check(i,j)) if (j - i + 1 > ans) ans = j-i+1, l = i, r = j; } for(i = l; i <= r; i++) cout<<s[i]; return 0; } Edited by author 13.02.2013 14:44 Edited by author 13.02.2013 14:45 |
|
|