Professional Documents
Culture Documents
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+A
Input
The first line of input contains an integer T<=500 i.e. the number of test cases. Each of the next T line contains a lowercase word (spell) of not more than 50 letters.
Output
For each test case print the number of unique letters present in that string. Answer each test case in a new line.
Sample Input
1 alohomora
Sample Output
6
Explanation
The word alohomora consists of 6 different alphabets i.e. a, l, o, h, m and r. Hence answer is 6.
1 of 1
1/23/2013 8:24 PM
Problem B
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+B
Time travellers
In the world of magic there exist a gate to travel in time. Magical authority has appointed Alice to keep a record of all the people passing through that gate. Every time a person goes inside that gate Alice writes an 'I' in a paper and every time a person comes out of the gate Alice writes down 'O'. Once, magical authority asked Alice about the number of peoples who have used that gate. Now looking at 'I' and 'O' at his paper it's impossible to tell the exact number of peoples who have used that gate but he's sure that there exist a method to know the minimum number of distinct peoples he could have seen passing through the gate. Can you write a code to know the minimum number of peoples he could have seen?
Input
First line of input contains a number T i.e. the number of test cases. Each of the next T lines contains a string S which is the record Alice has kept in his diary.
Output
Your code should print T lines each having one numbers, i.e. the minimum number of peoples he could have seen.
Sample Input
2 IOIOI OOO
Sample Output
1 3
1 of 1
1/23/2013 8:25 PM
Problem C
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+C
Input
First line of input is an integer T denoting the number of test cases. Next T line contains an integer X denoting the number of horcruxes Voldemort has.
Output
For each test case, your code should print the minimum number of clones required to destroy X horcruxes. Answer each test case in a new line.
Constraints1<=T<=1000 1<=X<=2000
Sample Input
2 78 42
Sample Output
12 6
1 of 1
1/23/2013 8:25 PM
Problem D
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+D
Decisions
Once little piglet plotted the graph of her town. Now she was amazed to know that there exist only one unique path from her house to her college, but there are many points in that path where she has to choose between 2 or more paths. Of course one path goes to the college and other one will lead her to a blocked end. You are given a graph she plotted in the form of a N*M grid. Each cell of the grid is either '.' , '*','M'or 'X'. Where '.' is empty cell and she can walk through it. '*' is the position of her college. 'M' is her house's location and 'X' is the blocked cell which she can't pass. From each cell she can go to any of its 4 neighbouring cell which are not blocked i.e. if she is in (x,y) she can move to (x+1,y),(x-1,y),(x,y-1) or (x,y+1). Now your task is to find the number of decisions she has to make in order to reach college from her house.
Input
First line of input contains a number T i.e. the number of test cases. First line of each test case contains two integers N and M. Next N lines contains a string with only '.', '*', 'M' or 'X' character and length M.
Output
Your code should print T lines each having one numbers, i.e. the number of decisions she has to make in order to reach her college from her house.
Constraints1<=T<=100 1<=N,M<=50
Sample Input
2 3 3 ... XMX ..* 2 3 *.M .X.
Sample Output
2 1
1 of 2
1/23/2013 8:25 PM
Problem D
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+D
Explanation
In the first test case, her starting location is (1,1) i.e. row 1 column 1, now from there she can either move to (0,1) or (2,1) so it's the first decision she made. Now when she reached point (2,1) she can either move to (2,2) or (2,0 ) and it's the second decision which she has to make.
2 of 2
1/23/2013 8:25 PM
Problem E
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+E
Input
First line of input contains a number T i.e. the number of test cases. First line of each test case contain a number N , which is the number of chocolates she has. Next line contains N numbers which are the weights of N chocolates.
Output
Your code should print T lines each having 2 numbers, first number should be the height of the tower with maximum chocolates and second number should be the number of towers.
Sample Input
2 3 4 4 2 5 1 3 3 1 2
Sample Output
2 2 2 3
Explanation
Here in the first test case we have 3 chocolates and their weights are 4,4 and 2 so we can make two towers, one of height 2 and one of height 1. Whereas in the second test case we can make 3 towers of height 2, 2 and 1.
1 of 1
1/23/2013 8:26 PM
Problem F
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+F
K-segments
Given an array of N elements. You have to divide it into K consecutive segments according to following rule(a) Suppose array is A[0 . . N] and you have to divide it into K consecutive segments. (b) All the segments are valid if and only if their intersection is NULL and their union is given array. (c) You need to create segments such that maximum of sum of numbers in each segment is minimum. See the first sample test case for better explanation.
Input
First line of input contains an integer T denoting number of test cases. Each test case is composed of 2 lines. First line contains two integers N and K. Next line contains N space separated integers which are the elements of given array.
Output
For each test case just print one integer, that is the answer to given test case. Answer each test case in a new line.
Sample Input
1 9 3 10 20 30 40 50 60 70 80 90
Sample Output
170
Explanation
You can divide the given array A[] into these 3 segments(i) A[0] to A[4] : sum= 150 (ii) A[5] to A[6] : sum= 130 (iii) A[7] to A[8]: sum= 170 Maximum of these sums is 170. There is no other way to choose 3 segments so as to minimize this maximum.
1 of 1
1/23/2013 8:26 PM
Problem G
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+G
Voldemort's Army
Voldemort is training his army of death eaters to finish Harry. To keep the training process easy for himself too, he wants to arrange the death eaters in the increasing order of their strength. Each death eater has some unique positive value of strength. Task is simple, he just need to sort the death eaters in the increasing order of strength. But Voldemort is not aware of any efficient sorting technique. He's using following algorithm in order to complete the task1. He will choose any K consecutive death eaters where K is less than or equal to total number of death eaters. 2. He will then reverse the order of those K death eaters. 3. He will perform above 2 operations until he found all the death eaters arranged in increasing order of their strength. Now this is a time consuming process, so Voldemort is interested in knowing the minimum number of times he has to apply above steps so as to complete the task and if it is impossible to obtain a sorted sequence of death eaters using this technique then simply print -1 .
Input
First line of input contains an integer T denoting number of test cases. First line of each test case contains two numbers N and K. Next line contains N space separated unique integers representing the strength of N death eaters.
Output
Print the minimum number of times he must use his algorithm to arrange death eaters in desired order or -1 if it is impossible to obtain required sequence using given algorithm. Answer each test case in a new line.
Sample Input
2 5 3
1 of 2
1/23/2013 8:26 PM
Problem G
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+G
5 4 1 2 3 5 4 3 2 4 1 5
Sample Output
3 -1
2 of 2
1/23/2013 8:26 PM
Problem H
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+H
Input
First line of input contains a number T i.e. the number of test cases. Each test case contains 2 lines. First lines contains a number N i.e. the number f chocolates in each box. Second line contains N space separated numbers denoting satisfaction factor associated with each chocolate.
Output
Your code should print T lines each having one numbers, i.e. the total satisfaction piglet will get from that chocolate box.
Sample Input
1 5 1 5 3 2 4
Sample Output
52
1 of 2
1/23/2013 8:27 PM
Problem H
http://192.168.4.179/~mooshak/cgi-bin/execute/678436515237?view+H
Explanation
Piglet will choose chocolates in following orderC[0]*1+C[4]*2+C[3]*3+C[2]*4+C[1]*5 == 1*1+4*2+2*3+3*4+5*5 == 52
2 of 2
1/23/2013 8:27 PM