diff --git a/src/P2758/P2758.cpp b/src/P2758/P2758.cpp new file mode 100644 index 0000000..fec42c8 --- /dev/null +++ b/src/P2758/P2758.cpp @@ -0,0 +1,44 @@ +#include +#include +#include + +using ll = long long; + +auto &is = std::cin;auto &os = std::cout; + +const ll max_n {2000+5}, ll_max{std::numeric_limits::max()}; +ll dp[max_n][max_n]{}; +std::string a,b; + +/* + dp[i][j]是前i个字符转化为j需要的最短编辑距离 +*/ + +int main(){ + is>>a>>b; + const ll a_size{(ll)a.size()}, b_size{(ll)b.size()}; + a=' '+a,b=' '+b; + // for(ll i{0};i +#include +// using namespace std; + +using ll = long long; + +const ll max_n = 400+5; +ll n,k; +ll a[max_n]; +ll dp[max_n][max_n], waste[max_n][max_n]; +/* +抓住所有蛇的总浪费空间最小值 +dp[i][j] 抓住第i条蛇,使用了j次调整大小的浪费空间的最小值 +i,j,k + k分为两段,1~k,k+1~i + dp[i][j] = min(dp[i][j], dp[k][j-1]+waste[k+1][i]) +waste[i][j] 从i~j浪费的数量 +*/ +const ll ll_max{std::numeric_limits::max()}; + +int main(){ + std::cin>>n>>k; + for(ll i{1};i<=n;i++)std::cin>>a[i]; + for(ll i{0};i +#include +#include + +using ll = long long; + +auto &is = std::cin; +auto &os = std::cout; + +const ll max_n{200+5}; +std::string a,b; +ll dp[max_n][max_n]; + +int main(){ + while (is>>a>>b) { + a=' '+a; + b=' '+b; + + for(ll i{1};i