1 solutions
-
0
记忆化搜索写法
是个人都看得懂,就不写思路了#include<bits/stdc++.h> using namespace std; string x;//Ab3bd int dp[1005][1005]; int p(int l,int r){ if(dp[l][r])return dp[l][r]; if(l>=r)return 0; if(x[l]==x[r])return p(l+1,r-1); else return dp[l][r]=min(p(l+1,r),p(l,r-1))+1; } int main(){ cin>>x; cout<<p(0,x.size()-1); return 0; }
- 1
Information
- ID
- 428
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 3
- Tags
- # Submissions
- 88
- Accepted
- 15
- Uploaded By