Test instructions
In a map, set the number of points that the RI can reach from point I.
Defines the minimum value for an "improved value" of the graph to be RI.
Now give a picture of the non-directed to each side to set a direction, so that the resulting directed graph "improved value" the largest.
Outputs the maximum modified value and the direction of the edge.
n,m≤400000
Exercises
For each "Edge double connected component" of undirected graphs, there must be a directional method to make the modified value equal to its size.
After the non-directed graph is shrunk, the maximum E-DCC is the zero-out point (end) BFS orientation
Each E-DCC internal DFS-directed
1#include <iostream>2#include <cstring>3#include <algorithm>4#include <cmath>5#include <cstdio>6#include <queue>7 using namespacestd;8 int Constn=400100;9 inthead[n],cnt;Ten intdfn[n],low[n],tot,flag[n*2]; One intC[n],t[n]; A intVis[n]; - intN,m,u[n],v[n],w[n],num; - structedge{ the intTo,nxt,flag; -}e[n*3]; - voidAddintUintv) { -cnt++; +e[cnt].nxt=Head[u]; -e[cnt].to=v; +head[u]=CNT; A } at voidTarjan (intUint from){ -dfn[u]=low[u]=++tot; - for(intI=head[u];i;i=e[i].nxt) { - intv=e[i].to; - if(!Dfn[v]) { - Tarjan (v,i); in if(e[i].flag==0&&e[i^1].flag==0) e[i].flag=1; -low[u]=min (low[u],low[v]); to if(dfn[u]<Low[v]) { +flag[i]=flag[i^1]=1; -e[i].flag=e[i^1].flag=0; the } * } $ Else if(I!= ( from^1)){Panax Notoginseng if(e[i].flag==0&&e[i^1].flag==0) e[i].flag=1; -low[u]=min (low[u],dfn[v]); the } + } A } the voidBFsintUintCol) { +queue<int>Q; - q.push (u); $c[u]=Col; $t[col]=1; - while(!Q.empty ()) { - intu=Q.front (); the Q.pop (); - for(intI=head[u];i;i=e[i].nxt) {Wuyi intv=e[i].to; the if(c[v]| | Flag[i])Continue; -c[v]=Col; Wut[col]++; - Q.push (v); About } $ } - } - voidDfsintu) { -vis[u]=1; A for(intI=head[u];i;i=e[i].nxt) { + intv=e[i].to; the if(vis[v]==0){ - if(C[u]!=c[v]) e[i].flag=1; $ Dfs (v); the } the } the } the intMain () { -scanf"%d%d",&n,&m); inCnt=1; the for(intI=1; i<=m;i++){ thescanf"%d%d",&u[i],&v[i]); About Add (U[i],v[i]); the Add (V[i],u[i]); the } theTarjan (1,0); + intmaxx=0, S; - for(intI=1; i<=n;i++){ the if(!c[i]) BFS (i,++num);Bayi if(t[num]>Maxx) { themaxx=T[num]; thes=num; - } - } theprintf"%d\n", Maxx); the for(intI=1; i<=n;i++){ the if(C[u[i]]==c[v[i]])Continue; the } - for(intI=1; i<=n;i++){ the if(!vis[i]&&c[i]==s) { the DFS (i); the Break;94 } the } the for(intI=2; i<=cnt;i+=2){ the if(e[i].flag==0) printf ("%d%d\n", u[i/2],v[i/2]);98 Elseprintf"%d%d\n", v[i/2],u[i/2]); About } - return 0;101}View Code
cf732f tourist reform (side double unicom)