답안 #40060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40060 2018-01-26T08:58:48 Z 5ak0 Torrent (COI16_torrent) C++14
컴파일 오류
0 ms 0 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){
        string kek1 = "";
        for (int j = i; j < s1.size(); ++j){
            kek1 += s1[j], 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

torrent.cpp: In function 'int calc(std::__cxx11::string)':
torrent.cpp:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s1.size(); ++i){
                       ^
torrent.cpp:26:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < s1.size(); ++j){
                           ^
torrent.cpp:27:28: error: 'kek2' was not declared in this scope
             kek1 += s1[j], kek2 = kek1;
                            ^
torrent.cpp: In function 'int main()':
torrent.cpp:38:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < s.size(); ++i){
                       ^