結果

問題 No.238 Mr. K's Another Gift
ユーザー tokkakatokkaka
提出日時 2016-08-04 23:13:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 100,000 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-24 15:34:24
合計ジャッジ時間 7,879 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 3 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1,770 ms
5,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <functional>
#include <tuple>
#include <climits>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <numeric>
#include <map>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

bool solve(string s, int count)
{
    bool success = true;
    for(int i=0; i<s.size()/2; i++) {
        if(s[i] == s[s.size()-i-1]) continue;
        else {
            success = false;
            if(count == 1) return false;
            string s1=s, s2=s;
            s1.insert(i, 1, s[s.size()-i-1]);
            s2.insert(s.size()-i, 1, s[i]);
            if(solve(s1, 1) || solve(s2, 1) ) return true;
        }
    }
    if(success) {
        if(count == 0) {
            s.insert(s.size()/2, 1, 'a');
        }
        cout << s << endl;
    } else {
        cout << "NA" << endl;
    }

    return true;
}

int main()
{
    string s;
    cin >> s;
    solve(s, 0);
}
0