One-way traffic In a certain town there are n intersections connected by two- and one-way streets. The town is very modern so a lot of streets run through tunnels or viaducts. Of course it is possible to travel between any two intersections in both w…
设f[u]为从度数0到u的路径条数,f2[u]为从u到n的路径条数. ans=max{f[x[i]]*f2[y[i]]}(1<=i<=m). #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define N 5001 typedef long long ll; #define M 50001 int e,v[M],first[N],next[M]; vo…
震惊!记忆化搜索忘记返回map值调了半小时! 边(u,v)的经过次数是:能到u的牛数*v到n的方案数.正反两次连边,dfs两次即可 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=5005,M=50005; int n,m,x[M],y[M],h[N],cnt,ans,f[N],g[N]; struct qwe { int ne,to; }e[M…