Language: C++

#include<bits/stdc++.h>
using namespace std;

const int n=200000; //グラフの最大頂点数
int g[n][n]={0}; //グラフの隣接行列
int visit[n] = {}; //探索チェック

void dfs(int n,int num){//s:始点, num:頂点数
    for(int i=0; i<num; i++){
      if(g[n][i]==1 && visit[i]==-1){
        g[i][n]=0;
        visit[i]=0;
        dfs(i, num);
      }
    }
    return;
}

void dfsflow(int n, int num, int f){
  for(int i=0; i<num; i++){
    if(g[n][i]==1){
      visit[i]+=f;
      dfsflow(i, num, f);
    }
  }
  return;
}

int main(){
  int N, Q;
  cin >> N >> Q;
  for(int i=1; i<N; i++){
    visit[i]=-1;
  }
  for(int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    g[a-1][b-1] = g[b-1][a-1] =1;
  }
  dfs(0, N);
  for(int i=0; i<Q; i++){
    int p, x;
    cin >> p >> x;
    visit[p-1]+=x;
    dfsflow(p-1, N, x);
  }
  for(int i=0; i<N; i++){
    cout << visit[i] << ' ';
  }
  cout << endl;
  return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:10:24: error: reference to 'visit' is ambiguous
   10 |       if(g[n][i]==1 && visit[i]==-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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~
a.cc:12:9: error: reference to 'visit' is ambiguous
   12 |         visit[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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~
a.cc: In function 'void dfsflow(int, int, int)':
a.cc:22:7: error: reference to 'visit' is ambiguous
   22 |       visit[i]+=f;
      |       ^~~~~
/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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~
a.cc: In function 'int main()':
a.cc:33:5: error: reference to 'visit' is ambiguous
   33 |     visit[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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~
a.cc:44:5: error: reference to 'visit' is ambiguous
   44 |     visit[p-1]+=x;
      |     ^~~~~
/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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~
a.cc:48:13: error: reference to 'visit' is ambiguous
   48 |     cout << visit[i] << ' ';
      |             ^~~~~
/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:6:5: note:                 'int visit [200000]'
    6 | int visit[n] = {}; //探索チェック
      |     ^~~~~