結果
問題 | No.2234 palindromer |
ユーザー |
|
提出日時 | 2023-07-13 13:11:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 888 bytes |
コンパイル時間 | 908 ms |
コンパイル使用メモリ | 107,856 KB |
最終ジャッジ日時 | 2025-02-15 10:09:44 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include<iostream>#include<set>#include<algorithm>#include<vector>#include<string>#include<set>#include<map>#include<numeric>#include<queue>#include<cmath>#include <unordered_set>using namespace std;typedef long long ll;const ll INF=1LL<<60;typedef pair<int,int> P;typedef pair<int,P> PP;const ll MOD=998244353;int main(){string A;cin>>A;int lenA=A.size();string revA=A;reverse(revA.begin(),revA.end());auto check=[](const string &S){int p=0,q=S.size()-1;while(p<q){if(S[p]!=S[q]) return false;p++;q--;}return true;};for(int i=lenA;i>=0;i--){string tmpA=A.substr(0,lenA-i);reverse(tmpA.begin(),tmpA.end());string cand=A+tmpA;if(check(cand)){cout<<cand<<endl;return 0;}}}