結果
問題 | No.238 Mr. K's Another Gift |
ユーザー |
![]() |
提出日時 | 2018-10-28 01:47:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 1,923 ms |
コンパイル使用メモリ | 204,384 KB |
最終ジャッジ日時 | 2025-01-06 14:55:56 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 WA * 2 |
ソースコード
#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; if (s.size() == 1) { cout << s.front() << s.front() << endl; return 0; } 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; }