제출 #265433

#제출 시각아이디문제언어결과실행 시간메모리
265433square1001Palindromes (APIO14_palindrome)C++14
8 / 100
492 ms131076 KiB
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; bool is_palindrome(string str) { for(int i = 0; i < str.size(); ++i) { if(str[i] != str[str.size() - i - 1]) { return false; } } return true; } int main() { string S; cin >> S; int N = S.size(); vector<string> pals; for(int i = 0; i < N; ++i) { for(int j = i + 1; j <= N; ++j) { if(is_palindrome(S.substr(i, j - i))) { pals.push_back(S.substr(i, j - i)); } } } sort(pals.begin(), pals.end()); int cont = 1; long long ans = 0; for(int i = 1; i <= pals.size(); ++i) { if(i == pals.size() || pals[i - 1] != pals[i]) { ans = max(ans, 1LL * cont * int(pals[i - 1].size())); cont = 1; } else ++cont; } cout << ans << endl; return 0; }

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

palindrome.cpp: In function 'bool is_palindrome(std::string)':
palindrome.cpp:7:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i = 0; i < str.size(); ++i) {
      |                 ~~^~~~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i = 1; i <= pals.size(); ++i) {
      |                 ~~^~~~~~~~~~~~~~
palindrome.cpp:29:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if(i == pals.size() || pals[i - 1] != pals[i]) {
      |      ~~^~~~~~~~~~~~~~
#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...