Furthermore, there is a glittering diamond embedded in each node. is an arbitrarily chosen integer, and it lights up all nodes in the subtree of. be the number of nodes lit up by the diamond on node. You are to choose the colours of each diamond, and maximize the mex function of — that is, the smallest non-negative integer not appearing in — the set of shininess values of all diamonds.
Goodbye and farewell. Good and well. A rooted tree of n n nodes is given. Each node u u has a colour c_u c u . Furthermore, there is a glittering diamond embedded in each node u u. Its colour d_u d u is an arbitrarily chosen integer, and it lights up all nodes in the subtree of u u whose colour equals d_u d u . Let k_u k u be the number of nodes lit up by the diamond on node u u, and this diamond gets a shininess value of k_u cdot d_u k u ⋅d u . You are to choose the colours of each diamond, and maximize the mex function of — that is, the smallest non-negative integer not appearing in — the set of shininess values of all diamonds.