#include #define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; #define ll long long #define maxn 200006 signed main() { IOS int n,m; cin>>n>>m; cout< for (int i = n,j=0; i >=0&&j<=m ; --i,++j) { cout< } return 0; }
#include #define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; #define ll long long #define maxn 505 int dp[maxn][maxn]; signed main() { IOS int n; cin>>n; string s; cin>>s; for (int i = 0; i for (int j = i; j dp[i][j]=j-i+1; } } for (int j = 1; j for (int i = j-1; i >=0 ; --i) { dp[i][j]=min(dp[i][j],min(dp[i][j-1]+1,dp[i+1][j]+1)); for (int k = i; k <=j ; ++k) { if(s[k]==s[i]){ dp[i][j]=min(dp[i][j],dp[i+1][k-1]+dp[k][j]); } } } } cout< return 0; }