# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
397369 | Pichon5 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 2 ms | 588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int dp[301][301];
string s;
int f(int b, int e){
if(e<b)return 0;
if(b==e)return 1;
if(dp[b][e]!=-1)return dp[b][e];
dp[b][e]=1;
for(int i=1;i<=e-b+1;i++){
if(i+i>e-b+1)break;
string A=s.substr(b,i);
string B=s.substr(e-i+1,i);
if(A==B){
dp[b][e]+=1+f(b+i,e-i);
}
}
return dp[b][e];
}
void init(){
for(int i=0;i<=300;i++){
for(int l=0;l<=300;l++)dp[i][l]=-1;
}
}
int main()
{
int n,t;
cin>>t;
while(t--){
cin>>s;
init();
int n=s.size();
cout<<f(0,n-1)<<endl;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |