"cf659e" New reform

Source: Internet
Author: User

Analysis reprinted from http://blog.csdn.net/yukizzz/article/details/51029628 test instructions:

Given the N and m two-way edges, change the bidirectional edge to one-way edge, and ask the minimum number of unreachable vertices?


If you cannot reach it, the entry level is 0.
DFS determines whether a ring exists in each of the connected blocks, and if there is a ring, it guarantees that each point in the ring has a degree greater than or equal to 1. Otherwise, the symbolizing, the head of the penetration is 0.

1 varHead,vet,next,flag:Array[1..200000] ofLongint;2 N,m,x,y,tmp,ans,tot,i:longint;3 4 procedureAdd (a,b:longint);5 begin6 Inc (TOT);7next[tot]:=Head[a];8vet[tot]:=b;9head[a]:=tot;Ten End; One  A procedureDFS (u,pre:longint); - varE,v:longint; - begin the  ifflag[u]=1  Then begintmp:=0; ExitEnd; -flag[u]:=1; -e:=Head[u]; -   whileE<>0  Do +  begin -v:=Vet[e]; +   ifV<>pre ThenDFS (v,u); Ae:=Next[e]; at  End; - End; -  - begin -Assign (input,'1.in'); Reset (input); -Assign (output,'1.out'); Rewrite (output); in readln (n,m); -   fori:=1  toM Do to  begin + read (x, y); - Add (x, y); the Add (y,x); *  End; $   fori:=1  toN DoPanax Notoginseng   ifflag[i]=0  Then -   begin thetmp:=1; +DFS (I,0); Aans:=ans+tmp; the   End; + writeln (ans); -//close (input); $//close (output); $ End.
View Code

"cf659e" New reform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.