/in/foo.cc: In function 'int main()':
/in/foo.cc:38:4: error: reference to 'next' is ambiguous
next[cnt] = head[p];
^~~~
/in/foo.cc:9:41: note: candidates are: int next [500005]
int f[500005],head[500005],data[500005],next[500005],last_w[500005],first_w[500005];
^~~~
In file included from /usr/include/c++/6/bits/stl_algobase.h:66:0,
from /usr/include/c++/6/algorithm:61,
from /in/foo.cc:4:
/usr/include/c++/6/bits/stl_iterator_base_funcs.h:205:5: note: template<class _ForwardIterator> _ForwardIterator std::next(_ForwardIterator, typename std::iterator_traits<_Iter>::difference_type)
next(_ForwardIterator __x, typename
^~~~
/in/foo.cc:58:29: error: reference to 'next' is ambiguous
for(j = head[i];j!=0;j = next[j]){
^~~~
/in/foo.cc:9:41: note: candidates are: int next [500005]
int f[500005],head[500005],data[500005],next[500005],last_w[500005],first_w[500005];
^~~~
In file included from /usr/include/c++/6/bits/stl_algobase.h:66:0,
from /usr/include/c++/6/algorithm:61,
from /in/foo.cc:4:
/usr/include/c++/6/bits/stl_iterator_base_funcs.h:205:5: note: template<class _ForwardIterator> _ForwardIterator std::next(_ForwardIterator, typename std::iterator_traits<_Iter>::difference_type)
next(_ForwardIterator __x, typename
^~~~