結果

問題 No.588 空白と回文
ユーザー ohreitetsu
提出日時 2017-11-07 14:19:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 580 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 55,516 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 04:42:22
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
		}
	}
	cout<<maxLen<<endl;
	return 0;
}
0