• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jul 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include<bits/stdc++.h>
2. using namespace std;
3.
4. bool visited;
5. int n;
6.
7. void recur(int pos,int graph)
8. {
9.     int i;
10.     if(visited[pos]==1)
11.         return;
12.     else
13.     {
14.         visited[pos]=1;
15.       //  cout<<pos+1<<' ';
16.         for(i=0; i<n; i++)
17.         {
18.             if(graph[pos][i]==1)
19.                 recur(i,graph);
20.         }
21.     }
22. }
23.
24. int main()
25. {
26.     int graph,i,j,k,x,y;
27.     cin>>n;
28.     for(i=0; i<n; i++)
29.     {
30.         for(j=0; j<n; j++)
31.         {
32.             cin>>graph[i][j];
33.         }
34.     }
35.     //memset(A,0,sizeof A);
36.     int count=0,max=0;
37.     for(k=0; k<n; k++)
38.     {
39.         memset(visited,0,sizeof(visited));
40.         visited[k]=-1;
41.         count=0;
42.         for(j=0; j<n; j++)
43.         {
44.               // cout<<"i is "<<j<<endl;
45.             if(visited[j]==0)
46.             {
47.                 count++;
48.                 recur(j,graph);
49.             }
50.         }
51.    //  cout<<"k="<<k<<"count= "<<count<<endl;
52.      if(count>1)
53.      {
54.         if(max<count)
55.             max=count;
56.          cout<<count<<endl;
57.      }
58.
59.     }
60.     cout<<max<<endl;
61.
62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!

Top
{"ft_lang_label":"__label__en","ft_lang_prob":0.5292197,"math_prob":0.97031224,"size":1227,"snap":"2019-35-2019-39","text_gpt3_token_len":421,"char_repetition_ratio":0.15126738,"word_repetition_ratio":0.1800948,"special_character_ratio":0.4392828,"punctuation_ratio":0.21454546,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95844126,"pos_list":[0,1,2,3,4,5,6,7,8,9,10],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-23T15:01:39Z\",\"WARC-Record-ID\":\"<urn:uuid:927ef4b7-1a53-4238-b469-19175ab4f922>\",\"Content-Length\":\"23689\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3c6fb5c5-45f0-4fd2-b41a-24476a900c75>\",\"WARC-Concurrent-To\":\"<urn:uuid:892f0977-9c37-4a60-badd-976c8eebc59e>\",\"WARC-IP-Address\":\"104.20.208.21\",\"WARC-Target-URI\":\"https://pastebin.com/xd3Zm4r4\",\"WARC-Payload-Digest\":\"sha1:7AWH4CJBMH3B3EDYUJIM4XCQMC5KW52W\",\"WARC-Block-Digest\":\"sha1:JUY35CTOENMDAWK6JMNIGGBIFV7HDQ2V\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027318421.65_warc_CC-MAIN-20190823130046-20190823152046-00164.warc.gz\"}"}