i first got the most farthest point from root and then got the farthest point from that point but i am getting TLE. can you please find the appropriate algorithm for this problem . thanks my code :http://www.ideone.com/k2mF5 GOT AC!!! THANKS ALL....
I am trying to solve this problem:http://www.spoj.com/problems/PT07Z/. I am trying to find the diameter of the tree by using double BFS but I am getting TLE. Here is my code: http://ideone.com/vC9vsd Thank you.
In an edge-weighted tree, the xor-length of a pathpis defined as the xor sum of the weights of edges onp: ⊕is the xor operator. We say a path the xor-longest path if it has the largest xor-length. Given an edge-weighted tree with n nodes, can you find the xor-longest path?
In an edge-weighted tree, the xor-length of a pathpis defined as the xor sum of the weights of edges onp: ⊕is the xor operator. We say a path the xor-longest path if it has the largest xor-length. Given an edge-weighted tree with n nodes, can you find the xor-longest path?
Problem : Given a tree, where each node is labelled using lowercase latin character. Find the longest palindromic path. (T <= 15 and N <= 5000) My Idea : Just like finding a longest palindromic substring, we maintain dp[i][j]. And process this dp from length = 1 to length = 2 ...