結果
問題 | No.238 Mr. K's Another Gift |
ユーザー |
![]() |
提出日時 | 2015-07-05 23:29:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 663 ms |
コンパイル使用メモリ | 63,444 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 23:56:11 |
合計ジャッジ時間 | 2,090 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <iostream> #include <algorithm> #include <cstdio> #include <queue> #include <vector> using namespace std; bool isPalin(string s){ for(int ctr1=0;ctr1<(s.length()+1)/2;ctr1++){ if(s[ctr1]!=s[s.length()-1-ctr1]) return false; } return true; } typedef long long ll; int main() { string s; cin>>s; for(int ctr1=0;ctr1<(s.length()+1)/2;ctr1++){ if(s[ctr1]!=s[s.length()-1-ctr1]){ string t=s; string ap; ap+=s[s.length()-1-ctr1]; t.insert(ctr1,ap); if(isPalin(t)){ cout<<t; return 0; } t=s; ap=s[ctr1]; t.insert(s.length()-ctr1,ap); if(isPalin(t)){ cout<<t; return 0; } cout<<"NA"; return 0; } } string t; t+=s[(s.length())/2]; s.insert(s.length()/2,t); cout<<s; return 0; }