結果

問題 No.238 Mr. K's Another Gift
ユーザー ふーらくたる
提出日時 2016-07-10 19:01:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 651 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 59,200 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-13 10:28:30
合計ジャッジ時間 6,333 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 5 TLE * 1 -- * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

string s;

bool IsPalindrome(string str) {
    bool same = true;
    for (int i = 0; i < str.size(); i++) {
        same &= str[i] == str[str.size() - i - 1];
    }
    return same;
}

void Solve() {
    for (int alpha = 'a'; alpha <= 'z'; alpha++) {
        for (int i = 0; i <= s.size(); i++) {
            s.insert(s.begin() + i, alpha);
            if (IsPalindrome(s)) {
                cout << s << endl;
                return;
            }
            s.erase(s.begin() + i);
        }
    }
    cout << "NA" << endl;
}

int main() {
    cin >> s;

    Solve();

    return 0;
}
0