Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
const int MAX = 100000;

bool graph[MAX][MAX];
int distA[MAX];
int distB[MAX];
bool visit[MAX];

void dfs(int x, int n, int count, bool a){
   if(visit[x]) return;
   visit[x] = true;
   if(a) distA[x] = count; else distB[x] = count;
   ++count;
   rep(i,n){
      if(graph[x][i] == false) continue;
      if(visit[i]) continue;
      dfs(i,n,count,a);
   }
}

int main()
{
   int n;
   cin >> n;

   // 5-7-4-1-2 
   //       L3-6
   // 1-4-2-3

   rep(i,n-1){
      int a,b;
      cin >> a >> b;
      --a; --b;
      graph[a][b] = true;
      graph[b][a] = true;
   }

   //それぞれからの距離を求める
   //フェネックA
   dfs(0,n,0,true);
   //リセット
   rep(i,n) visit[i] = false;
   //スヌケ
   dfs(n-1,n,0,false);

   int A = 0;
   int B = 0;

   rep(i,n){
      if(distA[i] <= distB[i]) A++;
      else B++;
   }

   if(A > B) cout << "Fennec" << endl;
   else cout << "Snuke" << endl;
   return 0;
}

Compiler output:
a.cc: In function 'void dfs(int, int, int, bool)':
a.cc:14:7: error: reference to 'visit' is ambiguous
   14 |    if(visit[x]) return;
      |       ^~~~~
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:11:6: note:                 'bool visit [100000]'
   11 | bool visit[MAX];
      |      ^~~~~
a.cc:15:4: error: reference to 'visit' is ambiguous
   15 |    visit[x] = true;
      |    ^~~~~
/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:11:6: note:                 'bool visit [100000]'
   11 | bool visit[MAX];
      |      ^~~~~
a.cc:20:10: error: reference to 'visit' is ambiguous
   20 |       if(visit[i]) continue;
      |          ^~~~~
/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:11:6: note:                 'bool visit [100000]'
   11 | bool visit[MAX];
      |      ^~~~~
a.cc: In function 'int main()':
a.cc:46:13: error: reference to 'visit' is ambiguous
   46 |    rep(i,n) visit[i] = false;
      |             ^~~~~
/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:11:6: note:                 'bool visit [100000]'
   11 | bool visit[MAX];
      |      ^~~~~