Submission #40059

# Submission time Handle Problem Language Result Execution time Memory
40059 2018-01-26T08:36:40 Z 5ak0 Palinilap (COI16_palinilap) C++14
0 / 100
1000 ms 2484 KB
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

string s;
int ans;

int calc(string s1){
    int res = 0;
    for (int i = 0; i < s1.size(); ++i){
        for (int j = i; j < s1.size(); ++j){
            string kek1 = s1.substr(i, j - i + 1), kek2 = kek1;
            reverse(kek2.begin(), kek2.end());
            res += (kek1 == kek2);
        }
    }
    return res;
}

int main(){
    cin >> s;
    ans = calc(s);
    for (int i = 0; i < s.size(); ++i){
        char ch = s[i];
        for (char j = 'a'; j <= 'z'; ++j){
            s[i] = j;
            ans = max(ans, calc(s));
        }
        s[i] = ch;
    }
    cout << ans;
    return 0;
}

Compilation message

palinilap.cpp: In function 'int calc(std::__cxx11::string)':
palinilap.cpp:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s1.size(); ++i){
                       ^
palinilap.cpp:25:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < s1.size(); ++j){
                           ^
palinilap.cpp: In function 'int main()':
palinilap.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); ++i){
                       ^
# Verdict Execution time Memory Grader output
1 Correct 856 ms 2020 KB Output is correct
2 Execution timed out 1000 ms 2020 KB Execution timed out
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 2020 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 2484 KB Execution timed out
2 Halted 0 ms 0 KB -