现在的位置: 首页 > 综合 > 正文

hdu2881

2013年10月07日 ⁄ 综合 ⁄ 共 766字 ⁄ 字号 评论关闭

/*
分析:
    dp。
    FUCK!,老纸跟multi的题杠上了!就算一星期也只能切一道题
我也跟你杠上了!!就算一道题要wa十几次或者几十次我也跟你杠
上了!!!尼玛天天折磨我很开心是不,啊?!次奥!!!老资
跟你杠上了!!!FUCK&&次奥!!!!!!

    垃圾代码垃圾方法,c++TLE,g++1000+ms
                                                        2013-04-11
*/

#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
using namespace std;
const int M=10005;

int n,m;
struct node{
	int t,x,y;
}E[M];
int dp[M];

int cmp(node n1,node n2){
	return n1.t<n2.t;
}
int main()
{
	int i,l;
	int temp;
	while(scanf("%d%d",&n,&m),n||m)
	{
		for(i=0;i<m;i++)	scanf("%d%d%d",&E[i].t,&E[i].x,&E[i].y);
		sort(E,E+m,cmp);

		int ans;
		ans=dp[0]=1;
		for(i=1;i<m;i++)
		{
			dp[i]=0;
			for(l=i-1;l>=0;l--)
			{
				temp=abs(E[i].x-E[l].x)+abs(E[i].y-E[l].y);
				if(temp>E[i].t-E[l].t)	continue;
				dp[i]=dp[i]>(dp[l]+1)?dp[i]:(dp[l]+1);
			}
			if(!dp[i])	dp[i]=1;
			if(dp[i]>ans)	ans=dp[i];
		}
		cout<<ans<<endl;
	}
	return 0;
}

抱歉!评论已关闭.