Guest User

Untitled

a guest
May 1st, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. set<lli> tot;
  2. map<lli,lli> colour1;
  3. void bfs1()
  4. {
  5.     queue<ll> q;
  6.     q.push({1,1});
  7.     while(!q.empty())
  8.     {
  9.         lli x=q.front().first;
  10.         lli y=q.front().second;
  11.         q.pop();
  12.         if(vis[x])
  13.         continue;
  14.         vis[x]=1;
  15.         set<lli> s;
  16.         for(int j=0;j<v[x].size();j++)
  17.         {
  18.             if(vis[v[x][j]]==0)
  19.             {
  20.                 q.push({v[x][j],x});
  21.             }
  22.             s.insert(colour1[v[x][j]]);
  23.         }
  24.         for(int i=1;i<=1000;i++)
  25.         {
  26.             if(s.count(i)==0)
  27.             {
  28.                 colour1[x]=i;
  29.                 tot.insert(i);
  30.                 break;
  31.             }
  32.         }
  33.         s.clear();
  34.     }
  35. }
Add Comment
Please, Sign In to add comment