結果

問題 No.599 回文かい
ユーザー ku_material_roku_material_ro
提出日時 2017-11-25 00:16:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,278 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 76,432 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-05 11:50:58
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 WA -
evil_0.txt WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	string s;
	string a[10000];
	string d1, d2;
	int size;
	int flag;
	int cnt = 0;
	cin >> s;
	size = s.size();
	int x = 0;
	int n = 0;
	//cout << size << endl;
	while (1){
		x++;
		d1 = s.substr(0, x);
		d2 = s.substr(size-x, x);


		if (d1 == d2){
			//cout << "TRUE"<< endl;
			a[n] = d1;
			s.erase(0, x);
			REP(i, x){
				s.pop_back();
			}
			//cout << s << endl;
			size = s.size();
			x = 0;
			n++;
		}
		if (size == 0){
			flag = 0;
			break;
		}else if (x == size / 2){
			a[n] = s;
			n++;
			flag = 1;
			break;
		}

		


	}
	//cout << n << endl;
	d1 = "";
	d2 = "";
/*	REP(i, n){
		cout << a[i] << endl;
	}*/
	if (flag == 1){
		cnt = n;
		for (int j = 2; j < n; j++){
			REP(i, n - j+1){
				REP(k, j){
					d1 = d1 + a[i+k];
					d2 = a[i+k] + d2;
					//cout << d1 << " " << d2 << endl;
				}
				if (d1 == d2){
					cnt += n - i - j;
				}
				d1 = "";
				d2 = "";
			}
		}


	}
	cout << cnt << endl;
	return 0;
}
0