poj~1236 Network of Schools Strong Connect entry question

Source: Internet
Author: User

Some schools connect to computer networks. An agreement has been reached between these schools:

Each school has a list of schools that distribute the software ("receiving school").

Please note that if B is in the distribution list of school A, then a does not necessarily appear in school B's list
You need to write a plan that calculates the minimum number of schools that must receive copies of the new software.

So that the software arrives at all schools on the network according to the Protocol (subtask a). As a further task,

We want to make sure that by sending a copy of the new software to any school, the software will overwrite all schools on the network.

To achieve this goal, we may need to expand the list of recipients of new members.

Calculate the minimum number of extensions that must be done so that we send new software to any school,

It will reach all other schools (Subtask B).

An extension implies the introduction of a new member into the recipient list of a school.

This problem is strong connected water problem, template title,

The first one asks for at least a few points to get to any point.

In fact, a strong connection to the point of contraction, to find a few degrees into the 0 points,

The second question to find out to add a few edges to the point after the direction of the non-circular graph into a strong connected graph

is to ask Max (Sumin, Sumout)

1#include <cstdio>2#include <cstring>3#include <string>4#include <algorithm>5#include <queue>6 using namespacestd;7 8 Const intMAXN = 1e5 +Ten;9 intN, M, U, V, tot, top, CNT, flag;Ten structNode { One     intV, next; A } EDGE[MAXN]; - intHEAD[MAXN], INSTACK[MAXN], S[MAXN]; - intDFN[MAXN], LOW[MAXN], BELONG[MAXN]; the voidinit () { -tot = CNT = top = Flag =0; -memset (s),0,sizeof(s)); -Memset (Head,-1,sizeof(head)); +memset (DFN,0,sizeof(DFN)); -memset (Instack,0,sizeof(Instack)); + } A voidAddintUintv) { atEDGE[TOT].V =v; -Edge[tot].next =Head[u]; -Head[u] = tot++; - } - voidTarjin (intv) { -DFN[V] = Low[v] = + +Flag; inINSTACK[V] =1; -s[top++] =v; to      for(inti = head[v]; I! =-1; i =Edge[i].next) { +         intj =edge[i].v; -         if(!Dfn[j]) { the Tarjin (j); *LOW[V] =min (Low[v], low[j]); $}Else if(Instack[j]) low[v] =min (Low[v], dfn[j]);Panax Notoginseng     } -     if(Dfn[v] = =Low[v]) { thecnt++; +         intT; A          Do { thet = s[--top]; +INSTACK[T] =0; -BELONG[T] =CNT; $} while(t! =v); $     } - } - voidsolve () { the      for(inti =1; I <= N; i++) -         if(!Dfn[i]) Tarjin (i);Wuyi } the int inch[MAXN], out[MAXN]; - intMain () { Wu      while(SCANF ("%d", &n)! =EOF) { - init (); AboutMemsetinch,0,sizeof(inch)); $Memset out,0,sizeof( out)) ; -          for(inti =1; I <= N; i++) { -             intv; -scanf"%d", &v); A              while(v) { + Add (i, v); thescanf"%d", &v); -             } $         } the          for(inti =1; I <= N; i++) the             if(!Dfn[i]) Tarjin (i); the          for(inti =1; I <= N; i++) { the              for(intj = Head[i]; ~j; j =Edge[j].next) { -                 if(BELONG[EDGE[J].V]! =Belong[i]) { in                     inch[belong[edge[j].v]]++; the                      out[belong[i]]++; the                 } About             } the         } the         intSumin =0, Sumout =0; the          for(inti =1; I <= CNT; i++) { +             if(!inch[i]) sumin++; -             if(! out[i]) sumout++; the         }Bayiprintf"%d\n", sumin); the         if(CNT = =1) printf ("0\n"); the         Elseprintf"%d\n", Max (Sumin, sumout)); -     } -     return 0; the}

poj~1236 Network of Schools Strong Connect entry question

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.