結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
hrbt__
|
| 提出日時 | 2019-12-10 20:14:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 988 bytes |
| コンパイル時間 | 1,854 ms |
| コンパイル使用メモリ | 162,916 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 02:11:00 |
| 合計ジャッジ時間 | 3,379 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#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;
}
if (n % 2 == 0) {
string t = s.substr(0, n / 2) + 'a' + s.substr(n / 2);
cout << t << endl;
} else {
string t = s.substr(0, n / 2) + s[n / 2] + s.substr(n / 2);
cout << t << endl;
}
}
hrbt__