Organized the next template ...
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <algorithm>5#include <queue>6#include <cstring>7 #definePAU Putchar (")8 #defineENT Putchar (' \ n ')9 using namespacestd;Ten Const intmaxn=100000+Ten, maxm=500000+Ten; One intLow[maxn],dfn[maxn],s[maxn],beg[maxn],top,scc,cz;BOOLINS[MAXN]; A structted{intX,Y;TED*NXT;} adj[maxm],*fch[maxn],*ms=adj; - voidAddintXintY) {*ms= (Ted) {x,y,fch[x]};fch[x]=ms++;return;} - voidTarjan (intu) { thelow[u]=dfn[u]=++cz;ins[u]=true; s[++top]=u; - for(ted*e=fch[u];e;e=e->NXT) { - intv=e->y;if(!dfn[v]) Tarjan (v), low[u]=min (low[u],low[v]); - Else if(Ins[v]) low[u]=min (low[u],dfn[v]); +}if(low[u]==Dfn[u]) { -scc++;intt=-1; while(t!=u) beg[t=s[top--]]=scc,ins[t]=false; +}return; A } atInlineintRead () { - intx=0, sig=1;CharCh=GetChar (); - while(!isdigit (CH)) {if(ch=='-') sig=-1; ch=GetChar ();} - while(IsDigit (CH)) x=Ten*x+ch-'0', ch=GetChar (); - returnx*=Sig; - } inInlinevoidWriteintx) { - if(x==0) {Putchar ('0');return;}if(x<0) Putchar ('-'), x=-x; to intlen=0, buf[ the]; while(x) buf[len++]=x%Ten, x/=Ten; + for(inti=len-1; i>=0; i--) Putchar (buf[i]+'0');return; - } the intn,m; * voidinit () { $N=read (); M=read ();intx, y;Panax Notoginseng while(m--) {X=read (); y=read (); Add (x, y);} - for(intI=1; i<=n;i++)if(!Dfn[i]) Tarjan (i); the for(intI=1; i<=n;i++){ +printf"%d:%d\n", I,beg[i]); A } the return; + } - voidWork () { $ return; $ } - voidprint () { - return; the } - intMain () {init (); work ();p rint ();return 0;}Wuyi /* the 5 5 - 1 2 Wu 2 3 - 3 4 About 4 5 $ 5 1 - */
Tarjan Shrinking Point