Language: C++

#include <iostream>

#include <deque>
#include <queue>
#include <map>

using namespace std;
#define INF 1500000000

 int N,A[200001];

 int prev[200001]={0} ; 
 int score[200001][2];
 int depth[200001];

int minweight(int vertex,int length);

map<int,int> mem_dp[200001];

int minweight(int vertex,int length){
 if(length<=0)
   return 0;
 if(vertex == 1){
	if(length<=1)
      return A[1];
	else
      return INF;
 }
 if(mem_dp[vertex].contains(length))
   return mem_dp[vertex][length];
 mem_dp[vertex][length] = min(minweight(prev[vertex],length),minweight(prev[vertex],length-1)<A[vertex]?A[vertex]:INF); 
  return mem_dp[vertex][length];
}

int main(){
 deque<int> nbd[200001];
 cin >> N;
 
  for(int i=1; i<=N; i++){
  	cin >> A[i];
  }
  for(int i=1; i<=N-1; i++){
    int u,v;
    cin >> u >> v;
    nbd[u].push_back(v);
    nbd[v].push_back(u);
  }
  
  queue<int> q;
  q.push(1);
  depth[1] = 1;
  prev[1] = -1;
  while(q.empty()==false){
    for(auto x:nbd[q.front()]){
     if(prev[x]==0){
      prev[x] = q.front(); 
      depth[x] = depth[prev[v]]+1;
      q.push(x);
     }
    }
    q.pop();
  }
  
  for(int k =1; k<=N; k++){
   cout << score[k][0] << endl; 
  }
  return 0;
}

Compiler output:
a.cc: In function 'int minweight(int, int)':
a.cc:29:20: error: 'class std::map<int, int>' has no member named 'contains'
   29 |  if(mem_dp[vertex].contains(length))
      |                    ^~~~~~~~
a.cc:31:41: error: reference to 'prev' is ambiguous
   31 |  mem_dp[vertex][length] = min(minweight(prev[vertex],length),minweight(prev[vertex],length-1)<A[vertex]?A[vertex]:INF);
      |                                         ^~~~
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:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc:31:72: error: reference to 'prev' is ambiguous
   31 |  mem_dp[vertex][length] = min(minweight(prev[vertex],length),minweight(prev[vertex],length-1)<A[vertex]?A[vertex]:INF);
      |                                                                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc: In function 'int main()':
a.cc:52:3: error: reference to 'prev' is ambiguous
   52 |   prev[1] = -1;
      |   ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc:55:9: error: reference to 'prev' is ambiguous
   55 |      if(prev[x]==0){
      |         ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc:56:7: error: reference to 'prev' is ambiguous
   56 |       prev[x] = q.front();
      |       ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc:57:24: error: reference to 'prev' is ambiguous
   57 |       depth[x] = depth[prev[v]]+1;
      |                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:12:6: note:                 'int prev [200001]'
   12 |  int prev[200001]={0} ;
      |      ^~~~
a.cc:57:29: error: 'v' was not declared in this scope
   57 |       depth[x] = depth[prev[v]]+1;
      |                             ^