結果

問題 No.273 回文分解
ユーザー newlife171128
提出日時 2018-01-28 20:11:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 160,036 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-29 15:03:29
合計ジャッジ時間 3,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 12 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>

typedef long long ll;
using namespace std;

typedef pair<int, int> P;



int main() {

	string s;
	cin>>s;

	int ans =0;

	for(int i=0; i<s.length()-1; i++){
		for(int j=i+1; j<s.length(); j++){
			string tmp = s.substr(i,j-i+1);

			string reve =tmp;

			reverse(reve.begin(),reve.end());

			if(tmp == reve){
				int a = tmp.length();
				ans = max(ans,a);
			}
		/*	cout<<tmp<<endl;*/
		}
	}
	if(ans ==0){
		cout<<1<<endl;
	}else if(ans ==2 && s.length() ==2){
		cout<<1<<endl;

	}else if(ans ==s.length()){
		cout<<ans-2<<endl;
	}

	return 0;
}
0