CCPC 长春 J - Abstract Painting

J - Abstract Painting

链接

题解

区间dp
dp[l][r][0] 表示 l ~ r 左端点在 l 右端点在 r 没有圆的种类数
dp[l][r][1] 表示 l ~ r 左端点在 l 右端点在 r 有圆的种类数
为什么要区分呢?
因为初始的时候就有一些圆,这些圆是必须存在的。所以这些点的dp[l][r][0] == 0.
因为圆的半径最多是5,所以区间dp 转移的时候 枚举中间点最多只用枚举5个就好。
转移方程:
l 的地方没有圆经过的情况:dp[l][r][0] = dp[l + 1][r][0] + dp[l + 1][r][1];
l 的地方有圆经过的情况:dp[l][r][0] = dp[l][k][1] * (dp[k][r][0] + dp[k][r][1]);
可是感觉dp[l][r][1]的情况也是这样的呀。。 但是初始圆必须放所以才分成了0,1.

代码:
#include<stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <string.h>
#include <iostream>
// #include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
#define pb push_back
#define mkp make_pair
#define st first
#define sd second
// const ll INF = 0x3f3f3f3f3f3f3f;
const double esp = 1e-9;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f;
//!!!!!!!!!!!!!!!!!!!!!!!!
const int<
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值