結果
問題 |
No.273 回文分解
|
ユーザー |
![]() |
提出日時 | 2016-03-15 02:44:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 558 bytes |
コンパイル時間 | 623 ms |
コンパイル使用メモリ | 59,864 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 13:15:12 |
合計ジャッジ時間 | 1,557 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 27 WA * 5 |
ソースコード
#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; } }