Submission #47240

#TimeUsernameProblemLanguageResultExecution timeMemory
47240marvenleePalindromes (APIO14_palindrome)C++14
23 / 100
1090 ms63044 KiB
#include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<string> ans; int maxans=0; int subans=0; string s; cin >> s; for(int i=0;i<s.length();i++) { for(int j=s.length()-1;j>=i;j--) { subans=0; int start=i,last=j,state=0; while(start<=last) { if(s[start]!=s[last]) { state=1; break; } start++;last--; } string s2= s.substr(i,j-i+1); if(state==0){ for(int x=0;x<ans.size();x++) { if(s2==ans[x]){ state=1; break; } } } if(state == 0) { string s2= s.substr(i,j-i+1); ans.push_back(s2); subans =s2.length(); int finaloccur = s.rfind(s2); int countoccur=1; int found=-1; while(s.find(s2,found+1)!=finaloccur) { countoccur+=1; found =s.find(s2,found+1); } subans*=countoccur; if(subans>maxans)maxans=subans; } } } cout << maxans; return 0; }

Compilation message (stderr)

palindrome.cpp: In function 'int main()':
palindrome.cpp:14:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.length();i++)
                 ~^~~~~~~~~~~
palindrome.cpp:31:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     for(int x=0;x<ans.size();x++)
                                 ~^~~~~~~~~~~
palindrome.cpp:50:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 while(s.find(s2,found+1)!=finaloccur)
                       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#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...