Skip to content

Commit

Permalink
Deleted Comments on Solution for 755C Codeforces (gopalgoel19#59)
Browse files Browse the repository at this point in the history
* 755C

* Added Solutions

* Updated 755C
  • Loading branch information
parthgpta authored and gopalgoel19 committed Oct 10, 2019
1 parent 6f99131 commit cc7b31c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions codeforces/C/755C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<bits/stdc++.h>
using namespace std;
map<int, vector<int> > mp;
vector< bool> b(10000,0);
vector<bool>visited(100000,0);

void dfs(long int n){
visited[n]=true;

for(int i=0;i<mp[n].size();i++){
if(!visited[mp[n][i]])
dfs(mp[n][i]);
}
}

int main(){
long int n,i,num,cou=0;
cin>>n;

for(i=1;i<=n;i++){
cin>>num;
mp[i].push_back(num);
mp[num].push_back(i);
}

for(i=1;i<=n;i++){

if(!visited[i]){
cou++;
dfs(i);
}
}
cout<<cou;

}

0 comments on commit cc7b31c

Please sign in to comment.