Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set<lli> tot;
- map<lli,lli> colour1;
- void bfs1()
- {
- queue<ll> q;
- q.push({1,1});
- while(!q.empty())
- {
- lli x=q.front().first;
- lli y=q.front().second;
- q.pop();
- if(vis[x])
- continue;
- vis[x]=1;
- set<lli> s;
- for(int j=0;j<v[x].size();j++)
- {
- if(vis[v[x][j]]==0)
- {
- q.push({v[x][j],x});
- }
- s.insert(colour1[v[x][j]]);
- }
- for(int i=1;i<=1000;i++)
- {
- if(s.count(i)==0)
- {
- colour1[x]=i;
- tot.insert(i);
- break;
- }
- }
- s.clear();
- }
- }
Add Comment
Please, Sign In to add comment