Language: C++

#include <bits/stdc++.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int limit = 110;
vector<int> tree[limit];
int par[limit];

void dfs(int v,int p,int d,vector<int> &dist){
	par[v] = p,dist[v] = d;
	for(auto &v2:tree[v]){
		if(v2 == p) continue;
		dfs(v2,v,d+1,dist);
	}
}

int max_depth,depth[limit];

void tree_travasal(int v,int p,int d){
	chmax(max_depth,d + 1);
	chmax(depth[d],tree[d].size() - 1);

	for(auto &v2:tree[v]){
		if(v2 == p) continue;
		tree_travasal(v2,v,d+1);
	}
}

const ll inf = 1LL << 60;

ll calc(int a,int b){
	max_depth = 1;
	rep(i,limit) depth[i] = 0;
	
	for(auto &c:{a,b}){		
		const int ab = a^b;
		string ret = tree_travasal(c,c^ab,0);
	}

	ll ret = 2LL;
	
	rep(i,max_depth){
		if(ret > inf/depth[i]) 
			ret = inf;
		else
			ret *= depth[i];
	}

	return ret;
}

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

	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		a--,b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	
	vector<int> udist(n,0),vdist(n,0);
	dfs(0,-1,1,udist);
	const int v = max_element(begin(udist),end(udist)) - begin(udist);

	dfs(v,-1,1,vdist);
	const int u = max_element(begin(vdist),end(vdist)) - begin(vdist);

	const int ans1 = (vdist[u] + 1) / 2;
	ll ans2 = inf;

	deque<int> roots;
	{
		int cur = u;
		while(cur != -1){
			roots.push_back(cur);
			cur = par[cur];
		}

		while(roots.size() > 2){
			roots.pop_front();
			roots.pop_back();
		}
	}


	if(roots.size() == 1){
		const int root = roots[0];
			
		for(auto &c:tree[root]) tree_travasal(c,root,0);
		ll ret = tree[root].size();

		rep(i,max_depth){
			if(ret > inf/depth[i]) 
				ret = inf;
			else
				ret *= depth[i];
		}

		chmin<ll>(ans2, ret);
		for(auto &c:tree[root]) chmin<ll>(ans2,calc(c,root));
	}else{
		const int a = roots[0], b = roots[1];
		chmin<ll>(ans2,calc(a,b));
	}

	cout << ans1 << " " << ans2 << endl;

	return 0;
}


Compiler output:
a.cc: In function 'void tree_travasal(int, int, int)':
a.cc:49:14: error: no matching function for call to 'chmax(int&, std::vector<int>::size_type)'
   49 |         chmax(depth[d],tree[d].size() - 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:21:23: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   21 | template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
      |                       ^~~~~
a.cc:21:23: note:   template argument deduction/substitution failed:
a.cc:49:14: note:   deduced conflicting types for parameter 'const T' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   49 |         chmax(depth[d],tree[d].size() - 1);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'll calc(int, int)':
a.cc:65:43: error: conversion from 'void' to non-scalar type 'std::string' {aka 'std::__cxx11::basic_string<char>'} requested
   65 |                 string ret = tree_travasal(c,c^ab,0);
      |                              ~~~~~~~~~~~~~^~~~~~~~~~