結果

問題 No.238 Mr. K's Another Gift
ユーザー hrbt__
提出日時 2019-12-10 20:12:40
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 862 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 163,016 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 02:10:56
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n / 2; i++) {
    if (s[i] == s[n - 1 - i]) continue;
    {
      string t = s.substr(0, n - i) + s[i] + s.substr(n - i);
      int m = t.length();
      for (int j = 0; j < m / 2; j++) {
        if (t[j] != t[m - 1 - j]) break;
        if (j == m / 2 - 1) {
          cout << t << endl;
          return 0;
        }
      }
    }
    {
      string t = s.substr(0, i) + s[n - 1 - i] + s.substr(i);
      int m = t.length();
      for (int j = 0; j < m / 2; j++) {
        if (t[j] != t[m - 1 - j]) break;
        if (j == m / 2 - 1) {
          cout << t << endl;
          return 0;
        }
      }
    }
    cout << "NA" << endl;
    return 0;
  }
  string t = s.substr(0, n / 2) + 'a' + s.substr(n / 2);
  cout << t << endl;
}
0