Language: C++

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, dist[100], dis[100];
bool vis[100];
vector<int>v[100];

void dfs(int x) {
	for (int i : v[x]) {
		if (!vis[i]) {
			vis[i] = true;
			dist[i] = dist[x] + 1;
			dfs(i);
		}
	}
}

int main() {
	cin >> N;
	for (int i = 1; i < N; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(0);
	pair<int, int>Max;
	for (int i = 0; i < N; i++) {
		Max = max(Max, make_pair(dist[i], i));
		dist[i] = 0;
		vis[i] = false;
	}
	dfs(Max.second);
	Max = make_pair(-1, -1);
	for (int i = 0; i < N; i++) {
		Max = max(Max, make_pair(dist[i], i));
		dis[i] = dist[i];
		dist[i] = 0;
		vis[i] = false;
	}
	dfs(Max.second);
	for (int i = 0; i < N; i++) {
		vis[i] = false;
	}
	if (Max.first & 1) {
		cout << Max.first / 2 + 1 << sp;
		queue<int>q;
		ll p = 2;
		for (int i = 0; i < N; i++) {
			if ((dis[i] == Max.first / 2 && dist[i] == Max.first / 2 + 1) || (dis[i] == Max.first / 2 + 1 && dist[i] == Max.first / 2)) {
				q.push(i);
				vis[i] = true;
			}
		}
		while (!q.empty()) {
			int n = q.size();
			unsigned a = 1;
			for (int i = 0; i < n; i++) {
				a = max(a, v[q.front()].size() - 1);
				for (int j : v[q.front()]) {
					if (!vis[j]) {
						vis[j] = true;
						q.push(j);
					}
				}
				q.pop();
			}
			p *= a;
		}
		cout << p << endl;
	}
	else {
		cout << Max.first / 2 + 1 << sp;
		int t;
		for (int i = 0; i < N; i++) {
			if (dis[i] == Max.first / 2 && dist[i] == dis[i]) {
				t = i;
				break;
			}
		}
		queue<int>q;
		ll res;
		ll p = v[t].size();
		q.push(t);
		vis[t] = true;
		while (!q.empty()) {
			int n = q.size();
			unsigned a = 1;
			for (int i = 0; i < n; i++) {
				a = max(a, v[q.front()].size() - 1);
				for (int j : v[q.front()]) {
					if (!vis[j]) {
						vis[j] = true;
						q.push(j);
					}
				}
				q.pop();
			}
			p *= a;
		}
		res = p;
		for (int i : v[t]) {
			for (int j = 0; j < N; j++) {
				vis[j] = false;
			}
			p = 2;
			q.push(t);
			q.push(i);
			vis[t] = vis[i] = true;
			while (!q.empty()) {
				int n = q.size();
				unsigned a = 1;
				for (int j = 0; j < n; j++) {
					a = max(a, v[q.front()].size() - 1);
					for (int k : v[q.front()]) {
						if (!vis[k]) {
							vis[k] = true;
							q.push(k);
						}
					}
					q.pop();
				}
				p *= a;
			}
			res = min(res, p);
		}
		cout << res << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:40: error: no matching function for call to 'max(unsigned int&, std::vector<int>::size_type)'
   67 |                                 a = max(a, v[q.front()].size() - 1);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:67:40: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   67 |                                 a = max(a, v[q.front()].size() - 1);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:67:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   67 |                                 a = max(a, v[q.front()].size() - 1);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:98:40: error: no matching function for call to 'max(unsigned int&, std::vector<int>::size_type)'
   98 |                                 a = max(a, v[q.front()].size() - 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:98:40: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   98 |                                 a = max(a, v[q.front()].size() - 1);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:98:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   98 |                                 a = max(a, v[q.front()].size() - 1);
      |                                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:122:48: error: no matching function for call to 'max(unsigned int&, std::vector<int>::size_type)'
  122 |                                         a = max(a, v[q.front()].size() - 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:122:48: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
  122 |                                         a = max(a, v[q.front()].size() - 1);
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
/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:122:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
  122 |                                         a = max(a, v[q.front()].size() - 1);
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~