結果
| 問題 | 
                            No.238 Mr. K's Another Gift
                             | 
                    
| コンテスト | |
| ユーザー | 
                             xuzijian629
                         | 
                    
| 提出日時 | 2018-10-28 01:46:42 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,289 bytes | 
| コンパイル時間 | 2,269 ms | 
| コンパイル使用メモリ | 203,748 KB | 
| 最終ジャッジ日時 | 2025-01-06 14:55:43 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
int main() {
    string s;
    cin >> s;
    deque<char> hoge;
    for (char c: s) {
        hoge.push_back(c);
    }
    string pref;
    while (hoge.size() > 1 && hoge.front() == hoge.back()) {
        pref.push_back(hoge.front());
        hoge.pop_front();
        hoge.pop_back();
    }
    string suf(pref);
    reverse(suf.begin(), suf.end());
    if (hoge.size() == 1) {
        cout << pref << hoge.front() << suf << endl;
        return 0;
    } else if (hoge.empty()) {
        cout << pref << "a" << suf << endl;
        return 0;
    }
    deque<char> fuga(hoge), piyo(hoge);
    fuga.push_back(hoge.front());
    piyo.push_front(hoge.back());
    auto tostr = [](deque<char> d) {
        string ret = "";
        for (char c: d) {
            ret += c;
        }
        return ret;
    };
    string sf = tostr(fuga), sp = tostr(piyo);
    auto ok = [](string t) {
        string u(t);
        reverse(u.begin(), u.end());
        return t == u;
    };
    if (ok(sf)) {
        cout << pref << sf << suf << endl;
        return 0;
    } else if (ok(sp)) {
        cout << pref << sp << suf << endl;
        return 0;
    }
    cout << "NA" << endl;
}
            
            
            
        
            
xuzijian629