제출 #998519

#제출 시각아이디문제언어결과실행 시간메모리
998519Ibrohim0704회문 (APIO14_palindrome)C++17
8 / 100
1102 ms1228 KiB
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

bool palin(std::string s) {
    if (s == std::string(s.rbegin(), s.rend())) {
        return true;
    }
    return false;
}

int cou(std::string s, std::string el) {
    int ret = 0;
    for (int i = 0; i < s.length(); i++) {
        int c = 0;
        for (int j = 0; j < el.length(); j++) {
            if (i + j < s.length()) {
                if (s[i + j] == el[j]) {
                    c++;
                }
            }
        }
        if (c == el.length()) {
            ret++;
        }
    }
    return ret;
}

int main() {
    std::string a;
    std::cin >> a;
    std::vector<int> ans;
    for (int i = 0; i < a.length(); i++) {
        for (int j = i; j < a.length(); j++) {
            std::string l = a.substr(i, j - i + 1);
            bool k = palin(l);
            if (k) {
                ans.push_back(l.length() * cou(a, l));
            }
        }
    }
    std::cout << *std::max_element(ans.begin(), ans.end()) << std::endl;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

palindrome.cpp: In function 'int cou(std::string, std::string)':
palindrome.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
palindrome.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int j = 0; j < el.length(); j++) {
      |                         ~~^~~~~~~~~~~~~
palindrome.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |             if (i + j < s.length()) {
      |                 ~~~~~~^~~~~~~~~~~~
palindrome.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if (c == el.length()) {
      |             ~~^~~~~~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < a.length(); i++) {
      |                     ~~^~~~~~~~~~~~
palindrome.cpp:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int j = i; j < a.length(); 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...