#include #include #include #include #include using namespace std; //tuple(t, x, y) int dist(const tuple& i, const tuple& j){ return ( abs(get<1>(i) - get<1>(j)) + abs(get<2>(i) - get<2>(j)) ); } int time(const tuple& i, const tuple& j){ return abs( get<0>(i) - get<0>(j) ); } int main(){ int n, m; cin >> n >> m; //n * n, m 个鼹鼠 vector> ham(m); vector dp(m, 1); for(int i = 0; i < m; i++){ int t, x, y; cin >> t >> x >> y; ham[i] = make_tuple(t, x, y); } //dp[m] = max (能走到的(t2 - t1 > dist)dp[x] + 1) for(int i = 1; i < m; i++){ for(int j = 0; j < i; j++){ //如果能走到就更新 if(dist(ham[i], ham[j]) <= time(ham[i], ham[j])){ dp[i] = max(dp[i], dp[j] + 1); } } } cout << *max_element(dp.begin(), dp.end()) << endl; return 0; }