結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2016-03-15 02:46:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 559 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 59,740 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 13:15:34 |
| 合計ジャッジ時間 | 1,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 4 |
ソースコード
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
bool check(const string &str){
string tmp = str;
reverse(tmp.begin(),tmp.end());
if(str == tmp) return true;
return false;
}
int main(){
string s;
cin >> s;
int n = s.size();
if(n == 2 || count(s.begin(),s.end(),s[0]) == n) cout << --n << endl;
else{
int ans = 1;
for(int i = 0;i < n;i++){
for(int j = 1;j <= n - i;j++){
if(check(s.substr(i,j))) ans = max(ans,j);
}
}
cout << ans << endl;
}
}
ldsyb