Algo-Trian
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user