Shashank and the Palindromic Strings

Shashank loves strings, but he loves palindromic strings the most. He has a list of n strings, A = [a0,a1,...,an-1] , where each string, ai, consists of lowercase English alphabetic letters. Shashank wants to count the number of ways of choosing non-empty subsequences s0,s1,s2,...,sn-1 such that the following conditions are satisfied: 1.s0 is a subsequence of string a0, s1 is a subsequence of string a1, s2 is a subsequence of string a2, ..., and sn-1 is a subsequence of string . 2. s-+s1+s2+

Points in a Plane

There are N points on an XY plane. In one turn, you can select a set of collinear points on the plane and remove them. Your goal is to remove all the points in the least number of turns. Given the coordinates of the points, calculate two things: The minimum number of turns (T) needed to remove all the points. The number of ways to to remove them in T turns. Two ways are considered different if any point is removed in a different turn. Input Format The first line contains the number of te

Turn Off the Lights

There are n bulbs in a straight line, numbered from 0 to n-1. Each bulb i has a button associated with it, and there is a cost,ci , for pressing this button. When some button i is pressed, all the bulbs at a distance <= k from bulb will be toggled(off->on, on->off). Given n, k, and the costs for each button, find and print the minimum cost of turning off all n bulbs if they're all on initially. Input Format The first line contains two space-separated integers describing the respective

Animal Transport

Capeta is working part-time for an animal shipping company. He needs to pick up animals from various zoos and drop them to other zoos. The company ships four kinds of animals: elephants, dogs, cats, and mice. There are m zoos, numbered 1 to m. Also, there are n animals. For each animal i, Capeta knows its type ti (E for elephant, D for dog, C for cat and M for mouse), source zoo si where Capeta has to pick it up from, and destination zoo di where Capeta needs to deliver it to. image Cap

The Indian Job

It is the Indian version of the famous heist “The Italian Job”. N robbers have already broken into the National Museum and are just about to get inside the main vault which is full of jewels. They were lucky that just as they broke into the museum, the guard was leaving the museum for exactly G minutes. But there are other problems too. The main vault has heat sensors that if at any moment of time there are more than two people present in the vault, the alarm goes off. To collect the jewels,