Codeforces Round #407 (Div. 2), problem: (D) Weird journey Solution in C

By |2017-04-09T01:29:16+00:00April 9th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<bits/stdc++.h> #define ll long long using namespace std; ll in[1000001]; vector<int>adj[1000001]; ll ans=0; bool g[1000001]; int dfs(int cur) { g[cur]=true; int k,cnt=1; for(k=0;k<adj[cur].size();k++) { if(g[adj[cur][k]]==false) { cnt+=dfs(adj[cur][k]); } } return cnt; }; ll ct[1000001]; int main() { int n,m,i,u,v; cin>>n>>m; for(i=0;i<m;i++) { scanf("%d%d",&u,&v); if(u==v) [...]