Atcoder Beginner Contest 284 E - Count Simple Paths Solution
Problem Link: https://atcoder.jp/contests/abc284/tasks/abc284_e
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
 - ///******Bismillahir-Rahmanir-Rahim******///
 - /// Abul Hasnat Tonmoy
 - /// Department of CSE,23rd batch
 - /// Islamic University,Bangladesh
 - ///**********ALLAH IS ALMIGHTY************///
 - #include <bits/stdc++.h>
 - using namespace std;
 - int vis[200009];
 - vector<int> adj[200009];
 - int ans ;
 - void dfs( int node ){
 - if(ans==1e6)
 - return;
 - vis[node]=1;
 - ans++;
 - for ( auto v : adj[node]){
 - if(!vis[v])
 - dfs(v);
 - }
 - vis[node]=0;
 - }
 - int32_t main() {
 - int n , e ;
 - cin >> n >> e ;
 - while ( e-- ){
 - int u , v ;
 - cin >> u >> v ;
 - adj[u].push_back(v);
 - adj[v].push_back(u);
 - }
 - ans = 0 ;
 - dfs (1) ;
 - cout<<ans<<endl;
 - }
 


No comments