답안 #312023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312023 2020-10-12T07:06:30 Z FatihSolak Palinilap (COI16_palinilap) C++14
0 / 100
1000 ms 21024 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    long long ans=0;
    long long arr[s.length()][26];
    for(int i=0;i<s.length();i++){
        for(int j=0;j<26;j++){
            arr[i][j]=0;
        }
    }
    for(int i=0;i<s.length();i++){
        for(int j=i;j<s.length();j++){
            string a="";
            for(int c=i;c<=j;c++){
                a +=s[c];
            }
            string b=a;
            reverse(a.begin(),a.end());
            if(b == a){
                ans++;
            }
            else{
                for(int h=0;h<(j-i)/2;h++){
                    if(b[h] != a[h]){
                        string d ="";
                        for(int c=i;c<=j;c++){
                            if(c == i+h || c == j-h){
                                continue;
                            }
                            d+=s[c];
                        }
                        string e=d;
                        reverse(d.begin(),d.end());
                        if(d==e){
                            arr[i][b[0]-'a']++;
                            arr[j][a[0]-'a']++;
                        }
                    }
                }
            }
        }
    }
    long long maxi=0;
    for(int i=0;i<s.length();i++){
        for(int j=0;j<26;j++){
            maxi = max(maxi,arr[i][j]);
        }
    }
    cout << maxi +ans;
}

Compilation message

palinilap.cpp: In function 'int main()':
palinilap.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<s.length();i++){
      |                 ~^~~~~~~~~~~
palinilap.cpp:13:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for(int i=0;i<s.length();i++){
      |                 ~^~~~~~~~~~~
palinilap.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int j=i;j<s.length();j++){
      |                     ~^~~~~~~~~~~
palinilap.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<s.length();i++){
      |                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 1280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1053 ms 21024 KB Time limit exceeded
2 Halted 0 ms 0 KB -