Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int int64_t
- using namespace std;
- int32_t main()
- {
- string s;
- cin >> s;
- vector<string> ans;
- for(int i = 0; i < s.size(); i++){
- for(int j = i; j < s.size(); j++){
- bool is_pl = true;
- for(int k = i; k <= j; k++)
- if(s[k] != s[j + i - k])
- is_pl = false;
- if(is_pl)
- ans.push_back(s.substr(i, j - i + 1));
- }
- }
- sort(ans.begin(), ans.end());
- cout << ans.back();
- }
Advertisement
Add Comment
Please, Sign In to add comment