結果

問題 No.599 回文かい
ユーザー aaaaaaaaaa
提出日時 2018-01-10 23:07:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,126 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 109,904 KB
実行使用メモリ 395,492 KB
最終ジャッジ日時 2023-08-25 10:41:15
合計ジャッジ時間 10,700 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 153 ms
187,792 KB
testcase_11 AC 93 ms
111,500 KB
testcase_12 AC 178 ms
212,512 KB
testcase_13 AC 112 ms
123,996 KB
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
evil_0.txt MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

vector<vector<int>> a;
string s;
int f(int x,int y){
	if(a[x][y]>0){
		return a[x][y];
	}
	if(x==y){
		return 1;
	}
	a[x][y]=1;
	rep(i,(y-x+1)/2){
		if(s.substr(x,i+1) == s.substr(y-i,i+1)){
			if((x+i+1)-(y-i-1)==1){
				a[x][y]++;
				a[x][y]=a[x][y]%mod;
			}else{
				a[x][y]+=f(x+i+1,y-i-1);
				a[x][y]=a[x][y]%mod;
			}
		}
	}
	return a[x][y];
}




int main(){
	
	
	cin>>s;
	int ss=s.size();
	a.resize(ss);
	rep(i,ss){
		a[i].resize(ss);
		rep(j,ss){
			a[i][j]=0;
		}
	}
	cout<<f(0,ss-1)<<endl;

}
0