Submission #976168

#TimeUsernameProblemLanguageResultExecution timeMemory
976168JahonaliXPalindromes (APIO14_palindrome)C++17
8 / 100
1045 ms131072 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long

bool is_palindrome(string a) {
    for (int i = 0; i < a.size(); ++i) {
        if (a[i] != a[a.size() - i - 1]) return false;
    }
    return true;
}

signed main() {
    string a;
    cin >> a;
    map<string, int> mp;
    for (int i = 1; i <= a.size(); ++i) {
        for (int j = 0; j <= a.size() - i; ++j) {
            mp[a.substr(j, i)]++;
        }
    }
    int mx = 0;
    for (int i = 1; i <= a.size(); ++i) {
        for (int j = 0; j <= a.size() - i; ++j) {
            string b = a.substr(j, i);
            if (is_palindrome(b)) {
                mx = max(mp[b] * (int) b.size(), mx);
            }
        }
    }
    cout << mx;
    return 0;
}

Compilation message (stderr)

palindrome.cpp: In function 'bool is_palindrome(std::string)':
palindrome.cpp:8:23: 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]
    8 |     for (int i = 0; i < a.size(); ++i) {
      |                     ~~^~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:18:23: 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]
   18 |     for (int i = 1; i <= a.size(); ++i) {
      |                     ~~^~~~~~~~~~~
palindrome.cpp:19:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   19 |         for (int j = 0; j <= a.size() - i; ++j) {
      |                         ~~^~~~~~~~~~~~~~~
palindrome.cpp:24:23: 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]
   24 |     for (int i = 1; i <= a.size(); ++i) {
      |                     ~~^~~~~~~~~~~
palindrome.cpp:25:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   25 |         for (int j = 0; j <= a.size() - i; ++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...