Escolar Documentos
Profissional Documentos
Cultura Documentos
Problems
A B C D E F G H I Car Game Peragrams Vacuum Tubes Chicken Joggers Hogwarts Bank Queue Forest Highway FreeCell Flag Quiz
SVART 100%
Task
For each set of three letters nd the rst word in a dictionary that contains these letters in the same order.
Input
The rst line of input contains two positive integers N 5 000 and M 10 000, the number of words in the dictionary and the number of license plates to be handled. Each of the following N lines contains a word from the dictionary, a string no more than 100 characters long containing only lower case letters from the English alphabet. This is followed by M lines each containing a string of three uppercase letters from the English alphabet, representing a license plate.
Output
For each license plate in the input you should output one line containing either the rst valid word in the dictionary or the sentence No valid word if no such word exists. Sample Input 1 5 3 banana car sand uncharacteristically counterrevolutionaries RRR DNA SND Sample Output 1 counterrevolutionaries No valid word sand
KTH Challenge 2013 Problem A: Car Game This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
Given a string, nd the minimum number of letters you have to remove from it, so that the string becomes a Peragram.
Input
Input consists of a string on a single line. The string will contain at least 1 and at most 1 000 characters. The string will only contain lowercase letters a-z.
Output
Output should consist of a single integer on a single line, the minimum number of characters that have to be removed from the string to make it a Peragram. Sample Input 1 abc Sample Input 2 aab Sample Output 1 2 Sample Output 2 0
KTH Challenge 2013 Problem B: Peragrams This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
Given a set of tube lengths and the two distances L1 and L2 , nd four tubes with the total length being as long as possible under the constraint that the sum of the rst two tube lengths is at most L1 and the sum of the last two tube lengths is at most L2 .
Input
The rst line of input contains three positive integers, L1 and L2 , denoting the distances explained above in mm (1 L1 , L2 10 000) and N , the number of available tubes (4 N 2 000). The following N lines each contain a single positive integer less than or equal to 10 000, the length of a tube in mm.
Output
Output one line containing the maximum total length of air that can be avoided, i.e., the sum of the four tubes chosen. If there are no two pairs of tubes tting into the setup, output the single word Impossible instead. Sample Input 1 1000 2000 7 100 480 500 550 1000 1400 1500 Sample Output 1 2930
KTH Challenge 2013 Problem C: Vacuum Tubes This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
KTH Challenge 2013 Problem C: Vacuum Tubes This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
You will be given a map of the woods and the jogging trails included in the minimum spanning tree created by the professors. It is guaranteed that there is exactly one route between each pair of intersections, where a route is a set of adjacent trails. Your task is to nd the minimum number of additional lamps you needed in order to satisfy the frightened runners, no matter which trails they use (subject to the restrictions above)
Input
Input starts with two integers N (2 N 50 000), and S (1 S 104 ), the number of intersections and the total distance in meters that a jogger wants to run, respectively. Then follow N 1 lines with three integers a (1 a N ), b (1 b N ), d (1 d 100), meaning that there is a bidirectional trail between intersection a and b with length d meters. KTH Challenge 2013 Problem D: Chicken Joggers This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5 7
Output
Output contains a single integer, the minimum number of additional lamps you need to place in order to satisfy the joggers requirements. Sample Input 1
SVART 100% PMS 657U 100%
Sample Output 1 1
5 1 1 4 3 1 1
6 2 3 3 5
1 1 3 2
Sample Input 2 5 1 1 4 3 1 3 6 2 3 3 5 1 1 3 2
Sample Output 2 1
Sample Input 3 5 1 1 1 1 2 4 6 3 4 5 2 3 3 2 3 2
Sample Output 3 1
KTH Challenge 2013 Problem D: Chicken Joggers This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
Find some sequence of at most 250 000 button presses that will change the staircase room from its current state to the desired state.
Input
There is a single test case. On the rst line N and M are given (3 N 50, 0 M N (N 1)/2). Then follow M lines with pairs of integers i, j (0 i, j N 1), describing the current state of the room of staircases. Each such line means that there is a staircase connecting oors i and j . After this follow another M lines with pairs of integers i, j , describing the desired state of the room of staircases.
Output
On the rst line of output, write a single integer Q (0 Q 250 000), the length of your sequence of button presses. Then print Q lines, each being either R i or G i for some i (0 i N 1), meaning that the red or green button on oor i should be pressed.
KTH Challenge 2013 Problem E: Hogwarts This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
Sample Output 1 2 R 0 G 2
4 1 3 2 4 2 4 3 4
PMS 657U 30%
Sample Input 2 3 0 0 1 0 1 0 3 1 2 2 1 2 2
Sample Output 2 0
KTH Challenge 2013 Problem E: Hogwarts 10 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
Help Oliver calculate how much cash he can get from the people currently standing in the queue before the bank closes by serving at most one person per minute.
Input
The rst line of input contains two integers N (1 N 10 000) and T (1 T 47), the number of people in the queue and the time in minutes until Oliver closes the bank. Then follow N lines, each with 2 integers ci and ti , denoting the amount of cash in Swedish crowns person i has and the time in minutes from now after which person i leaves if not served. Note that it takes one minute to serve a person and you must begin serving a person at time ti at the latest. You can assume that 1 ci 100 000 and 0 ti < T .
Output
Output one line with the maximum amount of money you can get from the people in the queue before the bank closes. Sample Input 1 4 4 1000 1 2000 2 500 2 1200 0 Sample Output 1 4200
KTH Challenge 2013 Problem F: Bank Queue 11 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
KTH Challenge 2013 Problem F: Bank Queue 12 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
You are given a description of the forest and the highway. The forest is a simple polygon, i.e. its sides do not cross, and the highway can be considered a straight line of width zero. You are also given d, the safe distance from the highway. Calculate the size of the inhabitable area of the forest.
Input
The rst line of the input contains one integer N (3 N 250 000) denoting the number of vertices of the polygon. N lines follow with two oating point numbers xi and yi , denoting that the i-th point of the polygon is (xi , yi ). Next line contains 4 oating point numbers xa , ya , xb , yb , denoting that the highway passes through points (xa , ya ) and (xb , yb ). The last line of the input contains one positive oating point number d, the safe distance from the highway. All oating point numbers will be at most 100 000 in absolute value and will have at most 4 digits after the decimal point.
KTH Challenge 2013 Problem G: Forest Highway 13 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
KTH Challenge 2013 Problem G: Forest Highway 14 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Figure H.1: Legal moves for the three of hearts and six of clubs
Most FreeCell computer games allow you to move a pile of cards, provided there are enough empty cells and empty stacks to accomplish this by moving cards from the pile one by one. In the image above for instance, the whole pile with 5, 4 and 3 can be moved over 6 of spades by using some of the free cells and the empty stack to temporarily hold 3 and 4.
Task
You would like to move a sorted pile of K cards from one stack to the top of another stack which is non-empty, but of appropriate color and value. You will ignore all other non-empty stacks, because otherwise you would have to take into account the color and value of the topmost card of those stacks and that would be too complicated. Even though you ignore the other non-empty stacks, you can still use N free cells and M empty stacks. Is it possible to perform this move?
KTH Challenge 2013 Problem H: FreeCell 15 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
Output
The program should print yes if it is possible to move a pile of K cards using N free cells and M empty stacks, and no otherwise.
SVART 100% PMS 657U 100%
Sample Input 1
PMS 657U 30%
3 1 8 Sample Input 2 3 1 9
KTH Challenge 2013 Problem H: FreeCell 16 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
SVART 100%
Task
Given a question and a set of potential answers to it, nd the answer that is easiest to change into any other answer.
Input
The rst line is the question to be answered. The next line contains one positive integer 1 N 100, giving the number of answer alternatives. The next N lines contain one alternative each. The alternatives are lists of parts, separated by a comma and a space. All answers have the same number of parts, at most 100. All parts are strings of letters a-z and A-Z, digits 0-9 and spaces. Each part doesnt contain leading or trailing spaces (except the space after a KTH Challenge 2013 Problem I: Flag Quiz 17 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5
Output
Output the alternative that requires the smallest maximum amount of changes to be turned into any other answer. If there are several least incongruous alternatives, output them all in the same order as in the input. Sample Input 1 The flag of the empire Angola? 4 Green stripe, black stripe, yellow Red stripe, black stripe, yellow Red stripe, black stripe, white Red stripe, green stripe, yellow
PMS 657U 30%
SVART 100%
Sample Output 1 Red stripe, black stripe, yellow Sample Input 2 The flag of the Knights who say Ni? 4 Black, white, pink, shrubbery Black, white, red, shrubbery Pink, white, red, shrubbery Black, pink, red, shrubbery Sample Output 2 Black, white, red, shrubbery
KTH Challenge 2013 Problem I: Flag Quiz 18 This work by KTH CSC is licensed under a Creative Commons Attribution-Share Alike 2.5