Rectangle Painting 1 Codeforces Round #576 (Div. 2)

链接: https://codeforces.com/contest/1199/problem/F
题面:
There is a square grid of size n×n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs max(h,w) to color a rectangle of size h×w. You are to make all cells white for minimum total cost.
The first line contains a single integer n (1≤n≤50) — the size of the square grid.
题意: 给你一个n*n的矩形,里面有黑色,白色,问你要将黑色涂成白色的最小花费,若所涂小矩形长宽为w,h,则花费为max(h,w);
思路: 我们意识到n很小,开个n^4都绰绰有余,我们意识到可以枚举每个子矩形,也就是爆搜,所以我们可以进行记忆化搜索,不断将一个大矩形切开变成小矩形,直到单独涂一格

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=55;
char mp[N][N];
int dp[N][N][N][N];
vector<int>ma;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值