A Telephone Line Company (TLC) is establishing a new telephone cable network. They are connecting several places numbered by integers from 1 to N . No two places have the same number. The lines are bidirectional and always connect together two places and in each place the lines end in a telephone exchange. There is one telephone exchange in each place. From each place it is
possible to reach through lines every other place, however it
need not be a direct connection, it can go through several exchanges.
From time to time the power supply fails at a place and then the
exchange does not operate. The officials from TLC realized that in such a
case it can happen that besides the fact that the place with the
failure is unreachable, this can also cause that some other places
cannot connect to each other. In such a case we will say the place
(where the failure
occured) is critical. Now the officials are trying to write a
program for finding the number of all such critical places. Help them.
by one space. Each block ends with a line containing just 0. The last block has only one line with N = 0;
5 5 1 2 3 4 0 6 2 1 3 5 4 6 2 0 0Sample Output
1 2Hint
1 #include<iostream> 2 #include<string.h> 3 #include<algorithm> 4 #include<queue> 5 #include<math.h> 6 #include<stdlib.h> 7 #include<stack> 8 #include<stdio.h> 9 #include<ctype.h> 10 #include<map> 11 #include<vector> 12 using namespace std; 13 vector<int>vec[1000]; 14 char ans[10000]; 15 bool flag[10000]; 16 int pre[1000]; 17 int low[1000]; 18 int tr[1000]; 19 int sizee = 0; 20 int dfs(int u,int fa); 21 int main(void) 22 { 23 int n; 24 while(scanf("%d",&n),n!=0) 25 { 26 sizee = 0; 27 int t; 28 memset(flag,0,sizeof(flag)); 29 memset(pre,0,sizeof(pre)); 30 memset(low,0,sizeof(low)); 31 memset(tr,0,sizeof(tr)); 32 for(int i = 0; i < 1000; i++) 33 vec[i].clear(); 34 while(scanf("%d",&t),t!=0) 35 { 36 int i,j; 37 int id; 38 gets(ans); 39 int l = strlen(ans); 40 int sum = 0; 41 for(i = 0; i <= l; ) 42 { 43 if(ans[i]>='0'&&ans[i]<='9') 44 { 45 sum = 0; 46 for(j = i; ans[j]!=' '&&ans[j]!='