Submission #980021

#TimeUsernameProblemLanguageResultExecution timeMemory
980021ElayV13Palindromes (APIO14_palindrome)C++17
0 / 100
538 ms131072 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int m_INF = -1e9+7; bool palindrom(string s){ reverse(s.begin(),s.end()); string z = s ; reverse(s.begin(),s.end()); if(z == s){ return true; } else{ return false; } } ll find_say_string(string s , string q) { ll say = 0 ; for(ll i = 0;i < s.size();i++){ string z = s.substr(i,i+q.size()); if(z == q) { say++; } } return say ; } void find_max_palindrom_on_string(string s) { ll l = 0 , r = s.size()-1 ; vector < string > palindroms ; vector < char > q ; if(palindrom(s)){ palindroms.push_back(s); } for(ll i = 0;i < s.size();i++){ q.push_back(s[i]); } while(r > 0) { string z = s.substr(l,r); if(palindrom(z) && z.size() != 1) { palindroms.push_back(z); } l++; if(l == r) { l = 0 ; r--; } } sort(palindroms.begin(),palindroms.end()); for(ll i = 0;i < palindroms.size();i++){ if(palindroms[i] == palindroms[i+1]){ palindroms.erase(palindroms.begin() + i); } } sort(q.begin(),q.end()); /////////////////////////////////////////////////////////////////////////////// int maks = m_INF ; for(ll i = 0;i < palindroms.size();i++) { string t = palindroms[i]; maks = max(maks,int(t.size())*(int((find_say_string(s,t))))); } for(ll i = 0;i < q.size();i++) { int say = 0 ; char c = q[i] ; for(ll j = 0;j < s.size();j++) { if(s[j] == c){ say++; } } maks = max(maks,say); } cout << maks << endl ; } signed main() { string s ; cin >> s ; find_max_palindrom_on_string(s); }

Compilation message (stderr)

palindrome.cpp: In function 'long long int find_say_string(std::string, std::string)':
palindrome.cpp:26:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(ll i = 0;i < s.size();i++){
      |                  ~~^~~~~~~~~~
palindrome.cpp: In function 'void find_max_palindrom_on_string(std::string)':
palindrome.cpp:50:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(ll i = 0;i < s.size();i++){
      |                  ~~^~~~~~~~~~
palindrome.cpp:75:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for(ll i = 0;i < palindroms.size();i++){
      |                  ~~^~~~~~~~~~~~~~~~~~~
palindrome.cpp:87:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |     for(ll i = 0;i < palindroms.size();i++)
      |                  ~~^~~~~~~~~~~~~~~~~~~
palindrome.cpp:94:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |     for(ll i = 0;i < q.size();i++)
      |                  ~~^~~~~~~~~~
palindrome.cpp:100:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |         for(ll j = 0;j < s.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...