結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
nanasili
|
| 提出日時 | 2015-10-07 18:18:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,338 bytes |
| コンパイル時間 | 753 ms |
| コンパイル使用メモリ | 75,084 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-20 01:54:41 |
| 合計ジャッジ時間 | 3,754 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 11 |
ソースコード
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
bool ok = true;
for (int i = 1, j = n-1; i < j; i++, j--) {
if (s[i] != s[j]) {
ok = false;
break;
}
}
if (ok) {
std::cout << s+s[0] << std::endl;
return 0;
}
ok = true;
for (int i = 0, j = n-2; i < j; i++, j--) {
if (s[i] != s[j]) {
ok = false;
break;
}
}
if (ok) {
std::cout << s[n-1]+s << std::endl;
return 0;
}
for (int i = 0, j = n-1; i < j; i++, j--) {
if (s[i] != s[j]) {
ok = true;
for (int k = i+1, l = j; k < l; k++, l--) {
if (s[k] != s[l]) {
ok = false;
}
}
if (ok) {
std::cout << s.substr(0, j+1)+s[i]+s.substr(j) << std::endl;
return 0;
}
ok = true;
for (int k = i, l = j-1; k < l; k++, l--) {
if (s[k] != s[l]) {
ok = false;
}
}
if (ok) {
std::cout << s.substr(0, i)+s[j]+s.substr(i-1) << std::endl;
return 0;
}
std::cout << "NA" << std::endl;
return 0;
}
}
std::cout << s.substr(0, n/2)+s[n/2]+s.substr(n/2) << std::endl;
}
nanasili