ProgMe

Task D

Dec 16th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define int int64_t
  3.  
  4. using namespace std;
  5.  
  6. int32_t main()
  7. {
  8. string s;
  9. cin >> s;
  10. vector<string> ans;
  11. for(int i = 0; i < s.size(); i++){
  12. for(int j = i; j < s.size(); j++){
  13. bool is_pl = true;
  14. for(int k = i; k <= j; k++)
  15. if(s[k] != s[j + i - k])
  16. is_pl = false;
  17. if(is_pl)
  18. ans.push_back(s.substr(i, j - i + 1));
  19. }
  20. }
  21. sort(ans.begin(), ans.end());
  22. cout << ans.back();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment