Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long s64;

const int ONE = 1000005;
const int MOD = 1e9 + 7;

int get()
{
		int res = 1, Q = 1; char c;
		while( (c = getchar()) < 48 || c > 57)
			if(c == '-') Q = -1;
		if(Q) res = c - 48;
		while( (c = getchar()) >= 48 && c <= 57)
			res = res * 10 + c - 48;
		return res * Q;
}

int n;
int next[ONE], first[ONE], go[ONE], tot;

void Add(int u, int v)
{
		next[++tot] = first[u], first[u] = tot, go[tot] = v;
		next[++tot] = first[v], first[v] = tot, go[tot] = u;
}

int x, y;
int SG[ONE], val[ONE];

void Dfs(int u, int father)
{
		int pd = 0;
		for(int e = first[u]; e; e = next[e])
		{
			int v = go[e];
			if(v == father || val[v] >= val[u]) continue;
			Dfs(v, u);
			if(SG[v] == 0) pd = 1;
		}
		SG[u] = pd;
}

int main()
{
		//freopen(".in","r",stdin);
		//freopen(".out","w",stdout);
		n = get();
		for(int i = 1; i <= n; i++) val[i] = get();
		for(int i = 1; i < n; i++)
			x = get(), y = get(), Add(x, y);
		for(int i = 1; i <= n; i++)
		{
			memset(SG, 0, sizeof(SG));
			Dfs(i, 0);
			if(SG[i]) printf("%d ", i);
		}

}

Compiler output:
a.cc: In function 'void Add(int, int)':
a.cc:30:17: error: reference to 'next' is ambiguous
   30 |                 next[++tot] = first[u], first[u] = tot, go[tot] = v;
      |                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:26:5: note:                 'int next [1000005]'
   26 | int next[ONE], first[ONE], go[ONE], tot;
      |     ^~~~
a.cc:31:17: error: reference to 'next' is ambiguous
   31 |                 next[++tot] = first[v], first[v] = tot, go[tot] = u;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:26:5: note:                 'int next [1000005]'
   26 | int next[ONE], first[ONE], go[ONE], tot;
      |     ^~~~
a.cc: In function 'void Dfs(int, int)':
a.cc:40:46: error: reference to 'next' is ambiguous
   40 |                 for(int e = first[u]; e; e = next[e])
      |                                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:26:5: note:                 'int next [1000005]'
   26 | int next[ONE], first[ONE], go[ONE], tot;
      |     ^~~~