{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003ch2\u003e Problem Statement \u003c/h2\u003e\n\nGiven a tree rooted at \u003cb\u003enode 1\u003c/b\u003e with \u003cb\u003eN\u003c/b\u003e nodes, each is assigned a lower case latin character. Print the sum of length of longest palindrome substring from string generated by simple path from root to all other nodes i.e root to some other node (say x) will represent a string, find its lps length and add it to answer for all such nodes x. Then print final answer.\u003cbr\u003e\u003cbr\u003e\n\n\u003ch2\u003e Input \u003c/h2\u003e\n\nEach test file contains a single test case. The first line contains the value of \u003cb\u003eN\u003c/b\u003e, the number of nodes in a tree. Next line contains a string of length N. The \u003cb\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/b\u003e character is the character assigned to node \u003cb\u003ei\u003c/b\u003e, where i belongs to \u003cb\u003e[1, N]\u003c/b\u003e. Next \u003cb\u003eN - 1\u003c/b\u003e lines contain 2 integers each, \"\u003cb\u003ex y\u003c/b\u003e\" which represent an edge from node \u003cb\u003ex\u003c/b\u003e to node \u003cb\u003ey\u003c/b\u003e.\u003cbr\u003e\u003cbr\u003e\n\n\u003ch2\u003e Output \u003c/h2\u003e\nOutput in a single line, an integer denoting the sum of length of longest palindromic substring of each string \u003cb\u003es\u003c/b\u003e which is formed by a simple path from root to all other nodes. \u003cb\u003eNote\u003c/b\u003e that root to root is a string of length 1.\u003cbr\u003e\u003cbr\u003e\n\n\u003ch2\u003e Constraints \u003c/h2\u003e\n1 ≤ N ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003cbr\u003e\u003cbr\u003e\n\n\u003ch2\u003eExample\u003c/h2\u003e\n\u003ch3\u003eInput\u003c/h3\u003e\n10\u003cbr\u003e\naaaaaaaaaa\u003cbr\u003e\n1 2\u003cbr\u003e\n2 3\u003cbr\u003e\n3 4\u003cbr\u003e\n4 5\u003cbr\u003e\n5 6\u003cbr\u003e\n6 7\u003cbr\u003e\n7 8\u003cbr\u003e\n8 9\u003cbr\u003e\n9 10\u003cbr\u003e\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n55"}}]}