[HNOI2004] 打鼹鼠 dp
作者:
多米尼克領主的致意
,
2024-05-24 13:14:55
,
所有人可见
,
阅读 3
《关于m<=1e4 却可以O(n^2)过这档事》
code:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int f[N];
struct node{
int t, x, y;
}mouse[N];
int n, m;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1;i <= m;i++){
f[i] = 1;
int t, x, y;
cin >> t >> x >> y;
mouse[i] = {t, x, y};
}
for(int i = 1;i <= m;i++){
for(int j = i - 1;j >= 1;j--){
auto a = mouse[i], b = mouse[j];
if(a.t - b.t >= abs(a.x - b.x) + abs(a.y - b.y)){
f[i] = max(f[i], f[j] + 1);
}
}
}
int ans = 0;
for(int i = 1;i <= m;i++){
ans = max(ans, f[i]);
}
cout << ans;
return 0;
}