結果
問題 | No.588 空白と回文 |
ユーザー |
|
提出日時 | 2017-11-07 14:20:37 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 194 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 964 ms |
コンパイル使用メモリ | 55,644 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-24 04:42:40 |
合計ジャッジ時間 | 2,392 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream>#include <string>using namespace std;int pairLen(string &s,int start,int len){int i,j;i=start;j=start+len-1;int aw=0;while (i<j){if (s[i]==s[j]){aw+=2;}i++;j--;}if (aw>0){if (i==j){aw++;}}return aw;}int main(int argc, char* argv[]){string s;cin>>s;int LEN=(int)s.length();int len,i;int maxLen=0;for (len=LEN;len>1;len--){for (i=0;i<=LEN-len;i++){int pLen=pairLen(s,i,len);if (maxLen<pLen){maxLen=pLen;}}if (maxLen>=len){break;}}if (maxLen==0){maxLen=1;}cout<<maxLen<<endl;return 0;}