結果

問題 No.273 回文分解
ユーザー cww
提出日時 2016-07-22 21:52:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 167,308 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 13:17:45
合計ジャッジ時間 2,917 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;
int main()
{
	string S;
	cin >> S;
	string str, tmp;
	int res{};
	REP( i, (int)S.size() )
	{
		str += S[i];
		REP2( j, i+1, (int)S.size() )
		{
			str += S[j];
			tmp = str;
			reverse( tmp.begin(), tmp.end() );
			if( tmp == str )
			{
				res = max( res, (int)str.size() );
				i += (int)str.size() - 1;
			}            
		}
		str.clear();
	}
	cout << ( res == 2 || res == 0 ? 1 : res ) << endl;
	return 0;
}
0