标签:dig vector opera include air class int its sig
dp,我们考虑到,这个其实你只需要按照边权排序,然后直接更新答案就完事了。
如果要求多维递增,那么就是个多维数点问题,查一下最值就可以了。
// by Isaunoya
#include<bits/stdc++.h>
using namespace std;
struct io {
char buf[1 << 23 | 3], *s;
int f;
io() { f = 0, buf[fread(s = buf, 1, 1 << 23, stdin)] = ‘\n‘; }
io& operator >> (int&x) {
for(x = f = 0; !isdigit(*s); ++s) f |= *s == ‘-‘;
while(isdigit(*s)) x = x * 10 + (*s++ ^ 48);
return x = f ? -x : x, *this;
}
};
const int maxn = 3e5 + 53;
vector <pair<int,int>> V[233333];
int dp[maxn], tmp[maxn];
signed main() {
#ifdef LOCAL
freopen("testdata.in", "r", stdin);
#endif
io in;
int n, m;
in >> n >> m;
while(m --) {
int u, v, w;
in >> u >> v >> w;
V[w].push_back({u, v});
}
for(int i = 1 ; i <= 1e5 ; i ++) {
for(auto x : V[i]) { tmp[x.first] = dp[x.first]; }
for(auto x : V[i]) {
int u = x.first, v = x.second;
dp[v] = max(dp[v], tmp[u] + 1);
}
}
int ans = 1;
for(int i = 1 ; i <= n ; i ++) ans = max(ans, dp[i]);
cout << ans << ‘\n‘;
return 0;
}
标签:dig vector opera include air class int its sig
原文地址:https://www.cnblogs.com/Isaunoya/p/12818952.html