Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
vector<int> g[100];

int dfs(int v, int par) {
    int res = 0;
    for (int to : g[v]) if (to != par) {
        res = max(res, dfs(to, v) + 1);
    }
    return res;
}

vector<int> mx;

void solve(int v, int par, int dist) {
    int cnt = 0;
    for (int to : g[v]) if (to != par) {
        ++cnt;
        solve(to, v, dist + 1);
    }
    mx[dist] = max(mx, cnt);
}

pair<int, LL> solve() {
    vector<int> cand;
    int mx = 0;
    forn(i, n) {
        int cur = dfs(i, -1);
        if (cur > mx) {
            mx = cur;
            cand.clear();
        }
        if (cur == mx) {
            cand.pb(i);
        }
    }
    assert((int)cand.size() == 1 || (int)cand.size() == 2);
    mx.assign(101, 0);
    int sz = cand.size();
    forn(i, sz) {
        solve(cand[i], (sz == 1 ? -1 : cand[i ^ 1]), 0);
    }
    int res1 = 0;
    LL res2 = 1;
    forn(i, 101) if (mx[i] > 0) {
        res1++;
        res2 *= mx[i];
    }
    return mp(res1, res2);
}

int main() {
    scanf("%d", &n);
    forn(i, n - 1) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    auto ans = solve();
    ++n;
    forn(i, n - 1) {
        g[i].pb(n - 1);
        g[n - 1].pb(i);
        ans = min(ans, solve());
        g[i].pop_back();
        g[n - 1].pop_back();
    }
    cout << ans.first << ' ' << ans.second << endl;
    return 0;
}



Compiler output:
a.cc: In function 'void solve(int, int, int)':
a.cc:30:19: error: no matching function for call to 'max(std::vector<int>&, int&)'
   30 |     mx[dist] = max(mx, cnt);
      |                ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:30:19: note:   deduced conflicting types for parameter 'const _Tp' ('std::vector<int>' and 'int')
   30 |     mx[dist] = max(mx, cnt);
      |                ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:30:19: note:   'std::vector<int>' is not derived from 'std::initializer_list<_Tp>'
   30 |     mx[dist] = max(mx, cnt);
      |                ~~~^~~~~~~~~
a.cc: In function 'std::pair<int, long long int> solve()':
a.cc:47:8: error: request for member 'assign' in 'mx', which is of non-class type 'int'
   47 |     mx.assign(101, 0);
      |        ^~~~~~
a.cc:54:24: error: invalid types 'int[int]' for array subscript
   54 |     forn(i, 101) if (mx[i] > 0) {
      |                        ^
a.cc:56:19: error: invalid types 'int[int]' for array subscript
   56 |         res2 *= mx[i];
      |                   ^