Language: C++

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int  visit[100005];
long long  dist[100005];
vector<int>vec[100005];
map<pair<int,int>,int>mp;
void bfs(int x)
{

   int s=x;
   visit[s]=1;
   queue<int>q;
   q.push(s);
   while(!q.empty()){
    int y=q.front();
    q.pop();
    for(int i=0;i<vec[y].size();i++)
    {
        if(visit[vec[y][i]]==0)
        {
            visit[vec[y][i]]=1;
            q.push(vec[y][i]);
            dist[vec[y][i]]=dist[y]+mp[{y,vec[y][i]}];
        }




    }




   }





}






int main()
{

int a,b,c,d,e;
cin >> a ;
set<int>s;
memset(visit,0,sizeof visit);
memset(dist,0,sizeof dist);
if(a==1)
{
    cout << 0 << endl;
}
else{

   a--;
while(a--)
{
    cin >> c >> d >> e;
    s.insert(c);
    s.insert(d);
    vec[c].push_back(d);
    vec[d].push_back(c);
    mp[{c,d}]=e;
    mp[{d,c}]=e;


}
bfs(c);
for(auto it=s.begin();it!=s.end();it++)
{
    if(dist[*it]%2==0)
    {
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }




}



}






}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:12:4: error: reference to 'visit' is ambiguous
   12 |    visit[s]=1;
      |    ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'int visit [100005]'
    4 | int  visit[100005];
      |      ^~~~~
a.cc:20:12: error: reference to 'visit' is ambiguous
   20 |         if(visit[vec[y][i]]==0)
      |            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'int visit [100005]'
    4 | int  visit[100005];
      |      ^~~~~
a.cc:22:13: error: reference to 'visit' is ambiguous
   22 |             visit[vec[y][i]]=1;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'int visit [100005]'
    4 | int  visit[100005];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:54:8: error: reference to 'visit' is ambiguous
   54 | memset(visit,0,sizeof visit);
      |        ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'int visit [100005]'
    4 | int  visit[100005];
      |      ^~~~~
a.cc:54:23: error: reference to 'visit' is ambiguous
   54 | memset(visit,0,sizeof visit);
      |                       ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:4:6: note:                 'int visit [100005]'
    4 | int  visit[100005];
      |      ^~~~~