結果
| 問題 |
No.273 回文分解
|
| ユーザー |
nmnmnmnmnmnmnm
|
| 提出日時 | 2015-02-13 22:32:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,375 bytes |
| コンパイル時間 | 950 ms |
| コンパイル使用メモリ | 89,336 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 13:22:19 |
| 合計ジャッジ時間 | 1,750 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define MOD 1000000007
int main(){
string s;
cin>>s;
int ans = 0;
rep(i,0,s.sz){
rep(j,i,s.sz){
string s1;
rep(k,i,j+1)s1+=s[k];
string s2 = s1;
reverse(all(s2));
if(s1==s2){
int len = j-i+1;
if(len != s.sz){
ans = max(ans,len);
}
}
}
}
cout << ans << endl;
return 0;
}
/*
実は文字列の中から最も長い回文を探すだけのハッタリ問題。
ただし最初から回文を与えられたときにそれを答えにできないので注意。
回文の判定は文字列を反転して元の文字列と同じかを判定すればできます。
普通に回文の要素もあるので本当に回文問題の練習に使えます。
*/
nmnmnmnmnmnmnm