結果
問題 | No.238 Mr. K's Another Gift |
ユーザー |
|
提出日時 | 2019-10-14 03:46:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 599 bytes |
コンパイル時間 | 741 ms |
コンパイル使用メモリ | 69,576 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 12:56:17 |
合計ジャッジ時間 | 2,895 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 5 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; string S,ans; main() { cin>>S; int N=S.size(); int id=0; for(;id<N/2&&S[id]==S[N-id-1];id++); if(id==N/2) { ans=S.substr(0,N/2)+S.substr(N/2,1)+S.substr(N/2); } else { string T=S.substr(0,id); T+=S[N-id-1]; T+=S.substr(id); bool flag=true; for(int i=0;i<T.size();i++)flag&=T[i]==T[T.size()-i-1]; if(flag)ans=T; else { T=S.substr(0,N-id); T+=S[id]; T+=S.substr(N-id); flag=true; for(int i=0;i<T.size();i++)flag&=T[i]==T[T.size()-i-1]; if(flag)ans=T; else ans="NA"; } } cout<<ans<<endl; }