Submission #134990

#TimeUsernameProblemLanguageResultExecution timeMemory
134990qrnoPalindromes (APIO14_palindrome)C++14
8 / 100
1080 ms62672 KiB
#include <iostream> #include <string> #include <map> using namespace std; map <string, int> M; inline bool isPalindrome(string s) { for (int i = 0; i < s.size(); i++) { if (s[i] != s[s.size()-i-1]) return false; } return true; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); string a; cin >> a; int ans = 0; for (int i = 0; i < a.size(); i++) { for (int j = i; j < a.size(); j++) { string s = ""; for (int m = i; m <= j; m++) { s += a[m]; } if (isPalindrome(s)) { M[s]++; int m = s.size(); ans = max(ans, m*M[s]); } } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

palindrome.cpp: In function 'bool isPalindrome(std::__cxx11::string)':
palindrome.cpp:9:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:26:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); i++) {
                     ~~^~~~~~~~~~
palindrome.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < a.size(); j++) {
                         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...