标签:时间 bre pre str 出现 turn include main 数据
//It is coded by Ning_Mew on 5.6
#include<bits/stdc++.h>
using namespace std;
const int maxm=1e4+7;
int n,m;
int x[maxm],y[maxm],t[maxm];
int dp[maxm],ans=0;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
scanf("%d%d%d",&t[i],&x[i],&y[i]);
dp[i]=1;
for(int j=1;j<i;j++){
if(t[j]==t[i])break;
if(abs(x[i]-x[j])+abs(y[i]-y[j])<=t[i]-t[j]) dp[i]=max(dp[i],dp[j]+1);
}
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
return 0;
}
//It is coded by Ning_Mew on 5.6
#include<bits/stdc++.h>
#define RE register
using namespace std;
const int maxm=1e4+7;
int n,m;
int x[maxm],y[maxm],t[maxm];
int dp[maxm],ans=0;
int main(){
scanf("%d%d",&n,&m);
for(RE int i=1;i<=m;i++){
scanf("%d%d%d",&t[i],&x[i],&y[i]);
dp[i]=1;
for(RE int j=1;j<i;j++){
//if(t[j]==t[i])break;
if(abs(x[i]-x[j])+abs(y[i]-y[j])<=t[i]-t[j])
dp[i]=max(dp[i],dp[j]+1);
}
ans=max(ans,dp[i]);
}
printf("%d\n",ans);
return 0;
}
【题解】 bzoj1207: [HNOI2004]打鼹鼠 (动态规划)
标签:时间 bre pre str 出现 turn include main 数据
原文地址:https://www.cnblogs.com/Ning-Mew/p/8999682.html