Test instructions: The input n,m represents n points, m edges, the maximum value of the product of the number of points of an ascending sequence and the point at which the end point is connected.
Analysis: DP run, Time complexity O (m).
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<cmath>#include<cstdlib>#include<map>using namespacestd;Long Longsum[100005];Long Longdp[100005];inthead[100005];structnode{intV,next;} g[200005];intk=1;voidAddintUintv) {G[K].V=v; G[k].next=Head[u]; Head[u]= k++;}intMain () {intN, M; intx, y; scanf ("%d%d", &n, &m); for(intI=1; i<=m; i++) {scanf ("%d%d", &x, &y); SUM[X]++; Sum[y]++; if(x<y) Add (y,x); ElseAdd (x, y); } Long LongAns =1; intv; for(intI=1; i<=n; i++) {Dp[i]=1; for(intJ=head[i]; j!=0; j=G[j].next) {v=g[j].v; Dp[i]= Max (dp[v]+1, Dp[i]); } ans=max (ans, sum[i]*Dp[i]); } printf ("%lld\n", ans); return 0;}
Codeforces 615B. Longtail Hedgehog