The main topic: given an no-map, require some points to be set to export requirements the graph of any one of the remaining points after the deletion of any point is connected with at least one outlet for the minimum number of exits and the minimum amount of program to build the export
The first thing I saw was a tarjan, but what?
First, let's say we pinch all the dots, so we can get a tree and we'll find out.
The leaf node (a point double with only one cut point) must be built because if the leaf node is not built, it will die if the cutting point is blown.
Non-leaf nodes (point pairs with two or more two cut points) do not need to be built because even if one of the cut points is blown, you can walk along another cut to a leaf node.
Another situation is that the entire Unicom block is point double (that is, the point double without cutting points) so we discuss the size of the point double
If there is only one point then this point must be built data no card this point so I did not write (actually I forgot to write and then pass)
If there are two or two or more points then you have to build two one is blown and you can go another
The number of schemes is a matter of multiplication principle. Note the leaf node where the exit cannot be built on the cutting point.
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 1010
using namespace Std;
typedef long Long LL;
struct abcd{int to,next;
}TABLE[M];
int head[m],tot=1;
int n,m,cases,ans1;
Long Long ans2;
int dpt[m],low[m],cnt,belong[m],stack[m],top;
inline void Initialize () {memset (head,0,sizeof head);
memset (dpt,0,sizeof DPT);
memset (belong,0,sizeof belong);
Tot=1;n=0;ans1=0;ans2=1;
} void Add (int x,int y) {table[++tot].to=y;
TABLE[TOT].NEXT=HEAD[X];
Head[x]=tot;
} void Tarjan (int x) {int i;
dpt[x]=low[x]=++cnt;
for (i=head[x];i;i=table[i].next) {int y=table[i].to;
if (Dpt[y]) low[x]=min (Low[x],dpt[y]);
else {Tarjan (y);
Low[x]=min (Low[x],low[y]);
if (low[y]>=dpt[x]) belong[x]++; }}} void _tarjAn (int x) {int i;
dpt[x]=low[x]=++cnt;
Stack[++top]=x;
for (i=head[x];i;i=table[i].next) {int y=table[i].to;
if (Dpt[y]) low[x]=min (Low[x],dpt[y]);
else {_tarjan (y);
Low[x]=min (Low[x],low[y]);
if (Low[y]>=dpt[x]) {int t,temp=0,size=0;
do{t=stack[top--];
if (belong[t]>=2) ++temp;
++size;
}while (t!=y);
T=x;
if (belong[t]>=2) ++temp;
++size;
if (!temp) ans1+=2,ans2*=size* (size-1)/2;
else if (temp==1) ans1++,ans2*=size-1;
}}}} int main () {//freopen ("2730.in", "R", stdin);
int i,x,y; WhilE (scanf ("%d", &m), m) {Initialize ();
for (i=1;i<=m;i++) {scanf ("%d%d", &x,&y);
N=max (N,X);
N=max (N,y);
ADD (x, y);
ADD (Y,X);
} for (i=1;i<=n;i++) if (!dpt[i]) Tarjan (i);
else belong[i]++;
memset (dpt,0,sizeof DPT);
for (i=1;i<=n;i++) if (!dpt[i]) _tarjan (i);
cout<< "Case" <<++cases<< ":";
cout<<ans1<< ' <<ans2<<endl;
}
}