标签:names codeforce return std class ring ++ tor mic
#include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector> #define maxn 300030 using namespace std; struct Node { int be; int en; int len; }que[maxn]; bool bml(Node a, Node b) { return a.len < b.len; } int n, m; int list[maxn]; int ans[maxn]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { scanf("%d%d%d", &que[i].be, &que[i].en, &que[i].len); } sort(que, que + m, bml); int t = 0; int xx = 0; for (int i = 0; i < m; i++) { int x = que[i].be; int p = que[i].en; int len = que[i].len; list[i] = ans[x] + 1; if (len != que[i + 1].len) { for (int j = t; j <= i; j++) { ans[que[j].en] = max(ans[que[j].en], list[j]); } t = i + 1; } xx = max(xx, list[i]); } printf("%d\n", xx); return 0; }
标签:names codeforce return std class ring ++ tor mic
原文地址:https://www.cnblogs.com/lesning/p/11888590.html