60 problems solved
Rank by points: #4953
Total points:
142
1 contest written
Rank by rating: #2367
Rating: 1362
Min. rating: 1362
Max rating: 1362
About
include <iostream>
include <queue>
using namespace std; int adj[230][230],i,j,a,b=1,c=1,d=0;bool vis[230]; queue<int> q; void bfs(int d){ q.push(d); while(!q.empty()){ if(vis[q.front()]==0){ for(i=1;i<=a;i++){ if(adj[q.front()][i]==1){ q.push(i); } } } if(q.front()==a){ d++; q.pop(); }else{ vis[q.front()]==1; q.pop(); } } cout<<d-1; } int main() { cout<<"enter a number:"; cin>>a; fill_n(&adj[0][0],230*230,0); while(b!=0&&c!=0){ cout<<"enter a link:"; cin>>b>>c; if(b!=0&&c!=0){ adj[b][c]=1; } } bfs(1); return 0; }
Rating history
, #