MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / bfs

Function bfs

HackerEarth_problems/Dhoom 4/solution.cpp:38–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36queue<int> q;
37int d[100005];
38void bfs(int x)
39{
40 q.push(x);
41 visited[x]=true;
42 d[x]=0;
43 while(!q.empty())
44 {
45 int cur=q.front();
46 q.pop();
47 if(cur==k)
48 {
49 return;
50 }
51 for (int i = 0; i < r; ++i)
52 {
53 int next=(1ll*a[i]*cur)%mod1;
54 if(!visited[next])
55 {
56 q.push(next);
57 visited[next]=true;
58 d[next]=d[cur]+1;
59 }
60 }
61 }
62}
63int main()
64{
65 ios_base::sync_with_stdio(false);//this works only

Callers 2

mainFunction · 0.85
flowMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected