Problema Not That Kind of Graph You know, it's all very sweet, stealing fiom the rich, selling to the poor Your task is to graph the price of a stock over time. In one unit of time, the stock can either Rise Fall or stay Constant. The stock's price will be given to you as a string of R's, F's and C's. You need to graph it using the characters '/'(slash), \'( backslash)and(underscore The first line of input gives the number of cases, N. N test cases follow. Each one contains a string of at least I and at most 50 upper case characters(R, F or C) output the line"Case #x: where x is the number of the test case. Then print the graph, as shown in the sample output, including the x- and y-axes. The x-axis should be one haracter longer than the graph, and there should be one space between the y-axis and the start of the graph. There should be no trailing spaces on any line. Do not print unnecessary lines. Finally, print an empty line after each test case le input Sample Outp Case #l RCRFCRFFCCRRC ∧A Problemsetter: Igor Naverniouk
1 Problem A Not That Kind of Graph Time Limit: 1 second "You know, it's all very sweet, stealing from the rich, selling to the poor..." Jose Molina, "Firefly." Your task is to graph the price of a stock over time. In one unit of time, the stock can either Rise, Fall or stay Constant. The stock's price will be given to you as a string of R's, F's and C's. You need to graph it using the characters '/' (slash), '\' (backslash) and '_' (underscore). Input The first line of input gives the number of cases, N. N test cases follow. Each one contains a string of at least 1 and at most 50 upper case characters (R, F or C). Output For each test case, output the line "Case #x:", where x is the number of the test case. Then print the graph, as shown in the sample output, including the x- and y-axes. The x-axis should be one character longer than the graph, and there should be one space between the y-axis and the start of the graph. There should be no trailing spaces on any line. Do not print unnecessary lines. Finally, print an empty line after each test case. Sample Input Sample Output 1 RCRFCRFFCCRRC Case #1: | _ | _/\_/\ / | / \__/ +--------------- Problemsetter: Igor Naverniouk
Problem b Lift Hopping Ted the bellhop: "I'm coming up and if there isn't a dead body by the time I get there, I'lI make one Robert rodriguez, "Four Rooms A skyscraper has no more than 100 floors, numbered from 0 to 99. It has n(1<=n<=5)elevators hich travel up and down at(possibly) different speeds. For each i in(1, 2,.n), elevator numbe takes Ti(I<=T<=100) seconds to travel between any two adjacent floors(going up or down) Elevators do not necessarily stop at every floor. What's worse, not every floor is necessarily accessible by an elevator You are on floor 0 and would like to get to floor k as quickly as possible. Assume that you do not need to wait to board the first elevator you step into and (for simplicity) the operation of switching an elevator on some floor always takes exactly a minute. Of course, both elevators have to stop at that floor. You are forbiden from using the staircase. No one else is in the elevator with you, so you don' t have to stop if you don't want to. Calculate the minimum number of seconds required to get from floor 0 to floor k(passing floor k while inside an elevator that does not stop there does not count as"getting to floor k") Input The input will consist of a number of test cases. Each test case will begin with two numbers, n and k, on a line. The next line will contain the numbers T1, T2, ..Tn. Finally, the next n lines will contain sorted lists of integers-the first line will list the floors visited by elevator number 1, the next one will list the floors visited by elevator number 2, etc Output For each test case, output one number on a line by itself -the minimum number of seconds required to get to floor k from floor 0. If it is impossible to do, print"IMPOSSIBLE"instead
2 Problem B Lift Hopping Time Limit: 1 second Ted the bellhop: "I'm coming up and if there isn't a dead body by the time I get there, I'll make one myself. You!" Robert Rodriguez, "Four Rooms." A skyscraper has no more than 100 floors, numbered from 0 to 99. It has n (1<=n<=5) elevators which travel up and down at (possibly) different speeds. For each i in {1, 2,... n}, elevator number i takes Ti (1<=Ti<=100) seconds to travel between any two adjacent floors (going up or down). Elevators do not necessarily stop at every floor. What's worse, not every floor is necessarily accessible by an elevator. You are on floor 0 and would like to get to floor k as quickly as possible. Assume that you do not need to wait to board the first elevator you step into and (for simplicity) the operation of switching an elevator on some floor always takes exactly a minute. Of course, both elevators have to stop at that floor. You are forbiden from using the staircase. No one else is in the elevator with you, so you don't have to stop if you don't want to. Calculate the minimum number of seconds required to get from floor 0 to floor k (passing floor k while inside an elevator that does not stop there does not count as "getting to floor k"). Input The input will consist of a number of test cases. Each test case will begin with two numbers, n and k, on a line. The next line will contain the numbers T1, T2,... Tn. Finally, the next n lines will contain sorted lists of integers - the first line will list the floors visited by elevator number 1, the next one will list the floors visited by elevator number 2, etc. Output For each test case, output one number on a line by itself - the minimum number of seconds required to get to floor k from floor 0. If it is impossible to do, print "IMPOSSIBLE" instead
Sample Outpu 230 105 0135791113152099 4131519202530 IMPOSSIBLE 05101214202530 246810121422252829 1050100 0103040 02030 02050 0246810 Explanation of examples In the first example, take elevator I to floor 13(130 seconds), wait 60 seconds to switch to elevator 2 and ride it to floor 30(85 seconds) for a total of 275 seconds In the second example, take elevator I to floor 10, switch to elevator 2 and ride it until floor 25 There, switch back to elevator I and get off at the 30'th floor. The total time is 10*10+60+15*1+60+5*10=285 seconds In example 3, take elevator 1 to floor 30, then elevator 2 to floor 20 and then elevator 3 to floor In the last example, the one elevator does not stop at floor I Problemsetter: Igor Naverniouk Alternate solutions: Stefan Pochmann frank pok man chu
3 Sample Input Sample Output 2 30 10 5 0 1 3 5 7 9 11 13 15 20 99 4 13 15 19 20 25 30 2 30 10 1 0 5 10 12 14 20 25 30 2 4 6 8 10 12 14 22 25 28 29 3 50 10 50 100 0 10 30 40 0 20 30 0 20 50 1 1 2 0 2 4 6 8 10 275 285 3920 IMPOSSIBLE Explanation of examples In the first example, take elevator 1 to floor 13 (130 seconds), wait 60 seconds to switch to elevator 2 and ride it to floor 30 (85 seconds) for a total of 275 seconds. In the second example, take elevator 1 to floor 10, switch to elevator 2 and ride it until floor 25. There, switch back to elevator 1 and get off at the 30'th floor. The total time is 10*10 + 60 + 15*1 + 60 + 5*10 = 285 seconds. In example 3, take elevator 1 to floor 30, then elevator 2 to floor 20 and then elevator 3 to floor 50. In the last example, the one elevator does not stop at floor 1. Problemsetter: Igor Naverniouk Alternate solutions: Stefan Pochmann, Frank Pok Man Chu
Problem c Lex smallest drive Time Limit. 2 seconds Bartholomew Furrow a graph, G, consists of a finite set of vertices, V, and a set of edges, E, where each edge is a set of 2 vertices ( u, vi. A walk in G is a finite sequence of vertices(V1, V2, ...,V), such that for each pair (Vi-l, Vi)for i in (2, k],ivi-I, Vii is in E. This is called a"walk from vi to vk". If v is a set integers, then any two walks in G can be compared lexicographically; for example, the walk(3, 5, 6, 2, 8)is smaller than the walk (3, 5, 6, 5, 7). A walk, w, from a to b is lexicographically smallest if there is no other walk from a to b in g that is smaller than w. a drive is a walk(v1, V2, .. vk) where no edge is used twice consecutively. That is, for all i from 2 up to k-1, Vi-1 is not equal to Given G and a start vertex, s, your task is to find the lexicographically smallest drives from s to each vertex in g Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing the integers n, m and s(0<=n<=100, 0<=m<=4950). The next m lines will list the edges of G. V is the set (0, 1,.., n-1. s is in v Output or each test case, output the line"Case #x: " where x is the number of the test case. Then print n lines, line i listing the lexicographically smallest drive from s to i using single spaces to separate consecutive vertices. If there is no such walk, print"No drive. " Put an empty line after each test case Sample Input Sample Output Case #1 645 40 No drive Problemsetter: Igor Naverniouk Alternate solution: Yury Kholondyrev
4 Problem C Lex Smallest Drive Time Limit: 2 seconds "OK. Let's go right." Bartholomew Furrow A graph, G, consists of a finite set of vertices, V, and a set of edges, E, where each edge is a set of 2 vertices {u, v}. A walk in G is a finite sequence of vertices (v1, v2, ..., vk), such that for each pair (vi-1, vi) for i in [2, k], {vi-1, vi} is in E. This is called a "walk from v1 to vk". If V is a set of integers, then any two walks in G can be compared lexicographically; for example, the walk (3, 5, 6, 2, 8) is smaller than the walk (3, 5, 6, 5, 7). A walk, W, from a to b is lexicographically smallest if there is no other walk from a to b in G that is smaller than W. A drive is a walk (v1, v2, ..., vk), where no edge is used twice consecutively. That is, for all i from 2 up to k-1, vi-1 is not equal to vi+1. Given G and a start vertex, s, your task is to find the lexicographically smallest drives from s to each vertex in G. Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing the integers n, m and s. (0 <= n <= 100, 0 <= m <= 4950). The next m lines will list the edges of G. V is the set {0, 1, ..., n-1}. sis in V. Output For each test case, output the line "Case #x:", where x is the number of the test case. Then print n lines, line i listing the lexicographically smallest drive from s to i using single spaces to separate consecutive vertices. If there is no such walk, print "No drive." Put an empty line after each test case. Sample Input Sample Output 1 6 4 5 5 0 2 5 4 0 3 1 Case #1: 5 0 No drive. 5 2 No drive. 5 0 4 5 Problemsetter: Igor Naverniouk Alternate solution: Yury Kholondyrev
Problem d Thunder mountain Time Limit. 3 seconds "I mean, some people got guns, and some people got flashlights, and some people got batteries. These guys had all three J. Michael Straczynski, "Jeremiah Markus is building an army to fight the evil Valhalla Sector, so he needs to move some supplies between several of the nearby towns. The woods are full of robbers and other unfriendly folk, so it's dangerous to travel far. As Thunder Mountain s head of security, Lee thinks that it is unsafe to carry supplies for more than 10km without visiting a town. Markus wants to know how far one would need to travel to get from one town to another in the worst case The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing n(the number of towns, 1<n<101). The next n lines will give the xy-locations of each town in km(integers in the range [0, 1023). Assume that the Earth is flat and the whole 1024x1024 grid is covered by a forest with roads connecting each pair of towns that are no further than 10km away from each other Output For each test case, output the line"Case #x: where x is the number of the test case. On the next line, print the maximum distance one has to travel from town a to town b (for some a and B) Round the answer to 4 decimal places. Every answer will obey the formula fabs(ans*le4- floor(ans*le4)-05)>1e-2 If it is impossible to get from some town to some other town, print"Send Kurdy"instead. Put an empty line after each test case Sample Input Sample Output Case #1 25.0000 00 100 Case #2 1010 Send Kurd 1310 1314 101
5 Problem D Thunder Mountain Time Limit: 3 seconds "I mean, some people got guns, and some people got flashlights, and some people got batteries. These guys had all three." J. Michael Straczynski, "Jeremiah." Markus is building an army to fight the evil Valhalla Sector, so he needs to move some supplies between several of the nearby towns. The woods are full of robbers and other unfriendly folk, so it's dangerous to travel far. As Thunder Mountain's head of security, Lee thinks that it is unsafe to carry supplies for more than 10km without visiting a town. Markus wants to know how far one would need to travel to get from one town to another in the worst case. Input The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing n (the number of towns, 1<n<101). The next n lines will give the xy-locations of each town in km (integers in the range [0, 1023]). Assume that the Earth is flat and the whole 1024x1024 grid is covered by a forest with roads connecting each pair of towns that are no further than 10km away from each other. Output For each test case, output the line "Case #x:", where x is the number of the test case. On the next line, print the maximum distance one has to travel from town A to town B (for some A and B). Round the answer to 4 decimal places. Every answer will obey the formula fabs(ans*1e4 - floor(ans*1e4) - 0.5) > 1e-2 If it is impossible to get from some town to some other town, print "Send Kurdy" instead. Put an empty line after each test case. Sample Input Sample Output 2 5 0 0 10 0 10 10 13 10 13 14 2 0 0 10 1 Case #1: 25.0000 Case #2: Send Kurdy