Submission #976172

#TimeUsernameProblemLanguageResultExecution timeMemory
976172JahonaliX회문 (APIO14_palindrome)C++17
8 / 100
1074 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;
    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);
            mp[b]++;
            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:19: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]
   19 |     for (int i = 1; i <= a.size(); ++i) {
      |                     ~~^~~~~~~~~~~
palindrome.cpp:20:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   20 |         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...