标签:acm dp codeforces
const int MAXN = 1100000;
int dp[MAXN], f[MAXN];
struct Edge
{
int u, v, d;
bool operator< (const Edge& rhs) const
{
return d < rhs.d;
}
} ipt[MAXN];
int main()
{
int n, m;
while (~RII(n, m))
{
CLR(dp, 0);
REP(i, m)
RIII(ipt[i].u, ipt[i].v, ipt[i].d);
sort(ipt, ipt + m);
REP(i, m)
{
int nxt = i;
while (nxt + 1 < m && ipt[i].d == ipt[nxt + 1].d)
nxt++;
FE(j, i, nxt)
{
int u = ipt[j].u, v = ipt[j].v;
f[v] = max(f[v], dp[u] + 1);
}
FE(j, i, nxt)
{
int v = ipt[j].v;
dp[v] = f[v];
}
i = nxt;
}
int ans = 0;
FE(i, 1, n)
ans = max(ans, dp[i]);
WI(ans);
}
return 0;
}Codeforces Round #261 (Div. 2)——Pashmak and Graph,布布扣,bubuko.com
Codeforces Round #261 (Div. 2)——Pashmak and Graph
标签:acm dp codeforces
原文地址:http://blog.csdn.net/wty__/article/details/38637829