摘要:
dp[x]表示1-x的划分最大和,最多从前面10个位置转移过来#include #include #include #include #include #define ll long long#define MAX_INT 2147483647using namespace std;int n,l;string s;ll dp[210],num[210][210];ll DP(int x){ if(x<=9&&num[0][x]<=MAX_INT) return num[0][x]; if(dp[x]!=-1) return dp[x]; ll ret=0; for 阅读全文
摘要:
用dp[x][y]表示以(x,y)点为右下角,所形成的图形的最大边长#include #include #include using namespace std;int n;char s[502][502];int dp1[502][502],dp2[502][502];int DP1(int x,int y){ if(s[x][y]=='.') return 0; if(x==0||y==0) return s[x][y]=='x' ? 1:0; if(dp1[x][y]!=-1) return dp1[x][y]; int ret=1000; ret=min 阅读全文
摘要:
该题的难点在于费用的计算,需考虑未来能转移到的所有状态用dp[l][r][next]表示l到r之间以及r之后与r同色的所有next个方块的最大费用和#include #include #include using namespace std;int t,n,a[202],k,cnt;int dp[202][202][202];struct block{ int x,c; block(){} block(int x,int c):x(x),c(c){}}b[202];void init(){ k=1,cnt=1; for(int i=1;i=r) return ne... 阅读全文