답안 #134890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134890 2019-07-23T11:32:20 Z qrno 회문 (APIO14_palindrome) C++14
8 / 100
1000 ms 61464 KB
#include <iostream>
#include <string>
#include <map>
using namespace std;

map <string, int> M;

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

int main() {

    string a;
    cin >> a;
    
    int ans = 0;

    for (int i = 0; i < a.size(); i++) {
        for (int j = i; j < a.size(); j++) {
            string s = "";
            for (int m = i; m <= j; m++) {
                s += a[m];
            }
            if (isPalindrome(s)) {
                M[s]++;
                int m = s.size();

                ans = max(ans, m*M[s]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Compilation message

palindrome.cpp: In function 'bool isPalindrome(std::__cxx11::string)':
palindrome.cpp:9:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); i++) {
                     ~~^~~~~~~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:23:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); i++) {
                     ~~^~~~~~~~~~
palindrome.cpp:24:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < a.size(); j++) {
                         ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 252 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 376 KB Output is correct
21 Correct 4 ms 256 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 4 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 4 ms 256 KB Output is correct
27 Correct 4 ms 376 KB Output is correct
28 Correct 5 ms 256 KB Output is correct
29 Correct 4 ms 256 KB Output is correct
30 Correct 4 ms 396 KB Output is correct
31 Correct 4 ms 376 KB Output is correct
32 Correct 4 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1065 ms 892 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 50420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 61464 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1022 ms 58484 KB Time limit exceeded
2 Halted 0 ms 0 KB -