noi 97 积木游戏

思路:黑书的例题

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define Maxn 110
#define Maxm 100010
#define LL __int64
#define Abs(x) ((x)>0?(x):(-x))
#define lson(x) (x<<1)
#define rson(x) (x<<1|1)
#define inf 0x7fffffff
#define Mod 1000000007
using namespace std;
int dp[][][][];
struct PP{
int h[];
}p[Maxn];
int check(PP a,int s1,PP b,int s2)
{
int x1,x2,y1,y2;
if(s1==){
x1=a.h[],y1=a.h[];
}
if(s1==){
x1=a.h[],y1=a.h[];
}
if(s1==){
x1=a.h[],y1=a.h[];
}
if(s2==){
x2=b.h[],y2=b.h[];
}
if(s2==){
x2=b.h[],y2=b.h[];
}
if(s2==){
x2=b.h[],y2=b.h[];
}
if(x1<=x2&&y1<=y2||x1<=y2&&y1<=x2)
return ;
return ;
}
int main()
{
int n,i,j,m,k,u,v;
while(scanf("%d%d",&n,&m)!=EOF){
memset(dp,,sizeof(dp));
for(i=;i<=n;i++){
scanf("%d%d%d",&p[i].h[],&p[i].h[],&p[i].h[]);
}
for(i=;i<=;i++){
dp[][][][i]=p[].h[i];
}
for(i=;i<=n;i++){
for(u=;u<=;u++){
dp[][i][i][u]=p[i].h[u];
}
}
for(i=;i<=m;i++){
for(j=i;j<=n;j++){
for(k=;k<j;k++){
for(u=;u<=;u++){
dp[i][j][k][u]=max(dp[i][j][k][u],dp[i][j-][k][u]);
for(v=;v<=;v++){
if(i<m){
dp[i+][j][j][u]=max(dp[i+][j][j][u],dp[i][j-][k][v]+p[j].h[u]);
}
if(check(p[j],u,p[k],v)){
dp[i][j][j][u]=max(dp[i][j][j][u],dp[i][j-][k][v]+p[j].h[u]);
}
}
}
}
}
}
int ans=;
for(i=m;i<=n;i++){
for(j=;j<=;j++){
ans=max(ans,dp[m][n][i][j]);
}
}
printf("%d\n",ans);
}
return ;
}
上一篇:C# 获取命名空间对应的程序集位置


下一篇:php 被抛弃使用的函数