結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2018-01-28 20:12:48 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 860 bytes |
コンパイル時間 | 1,307 ms |
コンパイル使用メモリ | 160,308 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-25 13:53:32 |
合計ジャッジ時間 | 2,351 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h>#include <iostream>#include <iomanip>#include <vector>#include <algorithm>#include <string>#include <sstream>#include <cmath>#include <stack>#include <queue>#include <cctype>#include <stdio.h>#include <map>#include <string.h>#include <utility>typedef long long ll;using namespace std;typedef pair<int, int> P;int main() {string s;cin>>s;int ans =0;for(int i=0; i<s.length()-1; i++){for(int j=i+1; j<s.length(); j++){string tmp = s.substr(i,j-i+1);string reve =tmp;reverse(reve.begin(),reve.end());if(tmp == reve){int a = tmp.length();ans = max(ans,a);}/* cout<<tmp<<endl;*/}}if(ans ==0){cout<<1<<endl;}else if(ans ==2 && s.length() ==2){cout<<1<<endl;}else if(ans ==s.length()){cout<<ans-2<<endl;}else{cout<<ans<<endl;}return 0;}