Algo-Trian

This commit is contained in:
e2hang
2025-09-21 12:21:50 +08:00
parent 24522486f1
commit 3bde00039c
25 changed files with 842 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
#include <iostream>
#include <tuple>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
//tuple(t, x, y)
int dist(const tuple<int, int, int>& i, const tuple<int, int, int>& j){
return ( abs(get<1>(i) - get<1>(j)) + abs(get<2>(i) - get<2>(j)) );
}
int time(const tuple<int, int, int>& i, const tuple<int, int, int>& j){
return abs( get<0>(i) - get<0>(j) );
}
int main(){
int n, m;
cin >> n >> m;
//n * n, m <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vector<tuple<int, int, int>> ham(m);
vector<int> 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 (<28><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>(t2 - t1 > dist)dp[x] + 1)
for(int i = 1; i < m; i++){
for(int j = 0; j < i; j++){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>͸<EFBFBD><CDB8><EFBFBD>
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;
}