結果

問題 No.273 回文分解
ユーザー zaichuzaichu
提出日時 2016-01-04 08:57:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 706 bytes
コンパイル時間 1,418 ms
コンパイル使用メモリ 144,836 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-08-25 01:28:51
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,504 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,376 KB
testcase_31 WA -
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0,check = 0;
	if(s.size() == 2) ans = 1;
	else{
		for(int i = 0; i < s.size()-ans; i++){
			for(int j = i + 1; j < s.size(); j++){
				if(s[i] == s[j]){
					//					cout << s[i] << " " << s[j] << endl;
					int x = j;
					for(int k = i+1; k <= (i+j)/2; k++){
						x--;
						//						cout << x << endl;
						//						cout << k << " " << x << endl;
						//						cout << s[k] << " " << s[x] << endl;
						if(s[k] == s[x]) check = 1;
						else{
							check = 0;
							break;
						}
					}
					if(check){
						ans = max(ans,j-i+1);
						check = 0;
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0