0 Up votes0 Down votes

23 views8 pagesNov 14, 2013

© Attribution Non-Commercial (BY-NC)

PDF, TXT or read online from Scribd

Attribution Non-Commercial (BY-NC)

23 views

Attribution Non-Commercial (BY-NC)

- 100911
- Design, Simulate and Analyze Cafeteria System Using Arena
- 168764-tkt-clil-part-2-resources.pdf
- dynetx
- Pseudo Lattice Graphs and their Applications to Fuzzy and Neutrosophic Models
- Complex Numbers Algebra
- Graph Presentation
- Networks Summary.docx
- CCP403
- 66% Partial Solution to the Chess Problem
- Graphs
- Tan an and Kumar Will Sky Tsp 10
- spfs1
- Modeling in Transportation Logistics Assignment.docx
- Lab10 Graphs
- Facebook Network Analysis Assignment
- Linkage learning using the maximum spanning tree of the dependency graph
- UT Dallas Syllabus for cs5333.001.10s taught by Nancy Van Ness (nancyvn)
- Credit Committee
- exploring patterns-20191206122507.docx

You are on page 1of 8

Input le: Output le: standard input standard output

Tim is an absolutely obsessive soda drinker, he simply cannot get enough. Most annoyingly though, he almost never has any money, so his only obvious legal way to obtain more soda is to take the money he gets when he recycles empty soda bottles to buy new ones. In addition to the empty bottles resulting from his own consumption he sometimes nd empty bottles in the street. One day he was extra thirsty, so he actually drank sodas until he couldnt aord a new one.

Input

Three non-negative integers e, f , c, where e < 1000 equals the number of empty soda bottles in Tims possession at the start of the day, f < 1000 the number of empty soda bottles found during the day, and 1 < c < 2000 the number of empty bottles required to buy a new soda.

Output

How many sodas did Tim drink on his extra thirsty day? standard input 9 0 3 5 5 2 4 9 standard output

Page 1 of 8

Input le: Output le: standard input standard output Most of the contestants managed to arrive at the Bolivian Algorithm Programming Contest on time. All except those unfortunate souls who chose to use a cheap car navigation system. A couple of wrong turns led them completely o course, and now they have ended up all over the world. Consider the case of contestant J.-P. B. (who has asked to remain anonymous). After driving for countless hours he found himself beneath three miles of water in the middle of the Atlantic Ocean. He was so focused on his navigation system that he failed to look outside until he noticed that the air was getting very moist. Fortunately for this contestant there was a spare submarine under his seat, which allowed him to escape this perilous situation. Tragic as this story seems, it is not even the worst. Another contestant, whom we will simply call S, wisely decided to travel by train. Sadly, she still listened to the advice of her evil car navigation system, and this morning she took a southbound train instead of heading north. After some more bad directions she found herself locked inside a labyrinth, in the pyramid of the Egyptian pharaoh Sok-O-Ban. As any experienced adventurer knows, these ancient tombs are often riddled with traps and other mechanisms. Sok-O-Bans nal resting place was no exception. During his lifetime this pharaoh was known for his sadistic behavior, and he liked to give impossible challenges to random strangers. It is therefore no coincidence that the cavern where contestant S ended up was completely closed o, surrounded by solid rock on every side. After looking around, our protagonist S managed to draw a map of the tomb. Fortunately she found no skeletons, mummies or spiked death traps. She did discover some buttons embedded in the oor tiles. If she could press them all at the same time, then the hidden exit would open. But as soon as she would release one of the buttons, the door would close again. Besides the buttons, the walls and a few dusty oor tiles, there were also two sarcophagi lled with rocks. To accommodate the small stature of the ancient Egyptians, the sarcophagi were cubes with sides measuring 1 meter, the same size as the oor tiles. It seemed that these sarcophagi were the key to escaping: by pushing them onto the buttons the exit could be kept open. Only one small problem remained: the sarcophagi were far too heavy to move by hand and too large to climb over. Fortunately for S, the pharaoh did not anticipate the portable sarcophagus transporter she had conveniently stashed in her backpack. Attaching this reusable system to her arms allowed her to eortlessly push a sarcophagus exactly one meter straight ahead. This corresponds nicely to the 1 meter steps S used when marking out the grid in her map.

Input

On the rst line of the input is a positive integer, the number of test cases. Then for each test case: A line containing two positive integers h, w 50, the height and width of the maze. h lines of w characters each, the map of the cavern our protagonist made, in which: # is a wall or otherwise impassible space. . is an empty space, of which there are at most 100. S is our protagonist. X is one of the heavy sarcophagi. There are at most two of these. B is a button. E is the exit. There is exactly one exit, on the edge of the map. The edge of the map contains only walls and the exit. Page 2 of 8

Output

For each test case: One line containing the minimum number of steps2 it will take S to escape the tomb, or the text impossible if she cannot escape.

standard input 3 7 8 ######## #..S...# #.####.# #.#.XB.# #.####.# #......E ######## 7 8 ######## #..S...# #.####.# #.#.BX.# #.####.# #......E ######## 4 8 ##E##### #...#### #SX.XBB# ######## impossible 10 19 standard output

Page 3 of 8

Input le: Output le: standard input standard output After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visited. Maybe you could have saved some money if you were a bit more clever about where you lled your fuel? To help other tourists (and save money yourself next time), you want to write a program for nding the cheapest way to travel between cities, lling your tank on the way. We assume that all cars use one unit of fuel per unit of distance, and start with an empty gas tank.

Input

The rst line of input gives 1 n 1000 and 0 m 10000, the number of cities and roads. Then follows a line with ith city. Then follow m lines with three integers 0 u, v < n and 1 d 100, telling that there is a road between uand v with length d. Then comes a line with the number 1 q 100, giving the number of queries, and q lines with three integers 1 c 100, s and e, where c is the fuel capacity of the vehicle, s is the starting city, and e is the goal.

Output

For each query, output the price of the cheapest trip from s to e using a car with the given capacity, or impossible if there is no way of getting from s to e with the given car.

standard input 5 5 10 10 20 12 13 0 1 9 0 2 8 1 2 1 1 3 11 2 3 7 2 10 0 3 20 1 4 170 impossible standard output

Page 4 of 8

Input le: Output le: standard input standard output

Misha is currently interested in undirected graphs that contain no two simple cycles sharing exactly one edge. Lets call them beautiful graphs. He wants to nd the maximal beatiful graph, that is the beautiful graph that contains the most edges among all beautiful graphs with at most n vertices. But Misha is going to leave on vacation, so he asked you to help him with this problem.

Input

The input le contains a single integer n(1 n 100) the maximum number of vertices your graph can contain

Output

Output the number of vertices V (1 V n) and the number of edges E of your graph to the rst line of the output le, separated with a space. Then output E lines with two integer numbers each, again separated with a space. The two numbers should be the numbers of the vertices connected by the corresponding edge. The vertices of the graph are numbered from 1 to V . You can output edges in any order. If there are several maximal graphs, output any.

standard input 1 2 3 1 2 1 3 1 2 1 0 1 2 3 2 3 3 standard output

Page 5 of 8

Input le: Output le: standard input standard output

A while ago I had trouble sleeping. I used to lie awake, staring at the ceiling, for hours and hours. Then one day my grandmother suggested I tried counting sheep after Id gone to bed. As always when my grandmother suggests things, I decided to try it out. The only problem was, there were no sheep around to be counted when I went to bed. Creative as I am, that wasnt going to stop me. I sat down and wrote a computer program that made a grid of characters, where # represents a sheep, while . is grass (or whatever you like, just not sheep). To make the counting a little more interesting, I also decided I wanted to count ocks of sheep instead of single sheep. Two sheep are in the same ock if they share a common side (up, down, right or left). Also, if sheep A is in the same ock as sheep B, and sheep B is in the same ock as sheep C, then sheeps A and C are in the same ock. Now, Ive got a new problem. Though counting these sheep actually helps me fall asleep, I nd that it is extremely boring. To solve this, Ive decided I need another computer program that does the counting for me. Then Ill be able to just start both these programs before I go to bed, and Ill sleep tight until the morning without any disturbances. I need you to write this program for me.

Input

The rst line of input contains a single number T , the number of test cases to follow. Each test case begins with a line containing two numbers, H and W , the height and width of the sheep grid. Then follows H lines, each containing W characters (either # or .), describing that part of the grid.

Output

For each test case, output a line containing a single number, the amount of sheep ocks on that grid according to the rules stated in the problem description. Notes and Constraints 0 < T 100 0 < H, W 100

standard input 2 4 4 #.#. .#.# #.## .#.# 3 5 ###.# ..#.. #.### 6 3 standard output

Page 6 of 8

Input le: Output le: standard input standard output Johnny drives a steam roller, which like all steam rollers is slow and takes a relatively long time to start moving, change direction, and brake to a full stop. Johnny has just nished his days work and is driving his steam roller home to see his wife. Your task is to nd the fastest path for him and his steam roller. The city where Johnny lives has a regular structure (the streets form an orthogonal system). The city streets are laid out on a rectangular grid of intersections. Each intersection is connected to its neighbors (up to four of them) by a street. Each street is exactly one block long. When Johnny enters a street, he must always travel to the other end (continue to the next intersection). From that point, he can continue in any of the four possible directions to another intersection, and so on. By studying the road conditions of the streets, Johnny has calculated the time needed to go from one end to the other of every street in town. The time is the same for both directions. However, Johnnys calculations hold only under the ideal condition that the steam roller is already in motion when it enters a street and does not need to accelerate or brake. Whenever the steam roller changes direction at a intersection directly before or after a street, the estimated ideal time for that street must be doubled. The same holds if the roller begins moving from a full stop (for example at the beginning of Johnnys trip) or comes to a full stop (for example at the end of his trip). The following picture shows an example. The numbers show the ideal times needed to drive through the corresponding streets. Streets with missing numbers are unusable for steam rollers. Johnny wants to go from the top-left corner to the bottom-right one.

The path consisting of streets labeled with 9s seems to be faster at the rst sight. However, due to the braking and accelerating restrictions, it takes double the estimated time for every street on the path, making the total time 108. The path along the streets labeled with 10s is faster because Johnny can drive two of the streets at the full speed, giving a total time of 100.

Input

The input consists of several test cases. Each test case starts with six positive integer numbers: R , C , r1 , c1 , r2 , and c2 . R and C describe the size of the city, r1 , c1 are the starting coordinates, and r2 , c2 are the coordinates of Johnnys home. The starting coordinates are dierent from the coordinates of Johnnys home. The numbers satisfy the following condition: 1 r1 , r2 R 100 , 1 c1 , c2 C 100 . After the six numbers, there are C - 1 non-negative integers describing the time needed to drive on streets between intersections (1,1) and (1,2), (1,2) and (1,3), (1,3) and (1,4), and so on. Then there Page 7 of 8

Bolivian Summer Training Camp Patacamaya Saturday, February 27, 2010 are C non-negative integers describing the time need to drive on streets between intersections (1,1) and (2,1), (1,2) and (2,2), and so on. After that, another C - 1 non-negative integers describe the next row of streets across the width of the city. The input continues in this way to describe all streets in the city. Each integer species the time needed to drive through the corresponding street (not higher than 10000), provided the steam roller proceeds straight through without starting, stopping, or turning at either end of the street. If any combination of one or more of these events occurs, the time is multiplied by two. Any of these integers may be zero, in which case the corresponding street cannot be used at all. The last test case is followed by six zeroes. All numbers are separated with at least one whitespace character (space, tab, or newline), but any amount of additional whitespace (including empty lines) may be present to improve readability.

Output

For each test case, print the case number (beginning with 1) followed by the minimal time needed to go from intersection r1 , c1 to r2 , c2 . If the trip cannot be accomplished (due to unusable streets), print the word Impossible instead.

standard input 4 4 1 1 10 10 9 0 0 0 0 0 9 0 0 9 0 0 0 9 0 0 9 9 2 2 1 1 0 0 0 0 4 4 10 10 10 10 2 2 0 1 1 0 0 0 standard output Case 1: 100 Case 2: Impossible

Page 8 of 8

- 100911Uploaded byijcnsVol2N09
- Design, Simulate and Analyze Cafeteria System Using ArenaUploaded byIonut Dumistrascu
- 168764-tkt-clil-part-2-resources.pdfUploaded byRachel Maria Ribeiro
- dynetxUploaded byMaz Har Ul
- Pseudo Lattice Graphs and their Applications to Fuzzy and Neutrosophic ModelsUploaded byAnonymous 0U9j6BLllB
- Complex Numbers AlgebraUploaded byMae Judelyn Pili
- Graph PresentationUploaded byAli Ali Raza
- Networks Summary.docxUploaded byAsare Amoafo
- CCP403Uploaded byapi-3849444
- 66% Partial Solution to the Chess ProblemUploaded bystephen ronald
- GraphsUploaded byharishpendela
- Tan an and Kumar Will Sky Tsp 10Uploaded bysreejithkuttikatt
- spfs1Uploaded bymaherkamel
- Modeling in Transportation Logistics Assignment.docxUploaded byYasith Weerasinghe
- Lab10 GraphsUploaded byJanus Baang Dadole
- Facebook Network Analysis AssignmentUploaded byAlex Leavitt
- Linkage learning using the maximum spanning tree of the dependency graphUploaded byMartin Pelikan
- UT Dallas Syllabus for cs5333.001.10s taught by Nancy Van Ness (nancyvn)Uploaded byUT Dallas Provost's Technology Group
- Credit CommitteeUploaded bymm8871
- exploring patterns-20191206122507.docxUploaded byAngela Sim
- NGDM07 Philip YuUploaded byapi-3798592
- hw3.pdfUploaded byNewton21st
- Graph AlgorithmsUploaded bygfdasdfghjkjhgc
- guided notes factoringUploaded byapi-376801179
- G10-CIRCINUS_SCIENCE-10-GRADESUploaded byGirlie Mae Pondias
- Functions IIT Prev(FCT)Uploaded byRajat Kalia
- A note on competitive diffusion through social networksUploaded bymareyi
- chap15Uploaded byAmjad Hussain Zahid
- James Conant- Vassiliev Invariants and Embedded GropesUploaded byMopadDeluxe
- 33 bus.pdfUploaded byRajesh Kumar

- the physics of music by David R. LappUploaded bydomakana
- Developer's Guide to Microsoft Enterprise Library - 2nd EditionUploaded bymanavsharma
- qosmio_X875-Q7390Uploaded byFernando Mori
- CUDNN Library (1)Uploaded byAriel Lenis
- Standard Music Notation PracticeUploaded byfakhribabiker
- PS2-VGAUploaded byAdnan Hayat
- LM35 Temperature SensorUploaded byapi-3799604
- 2011. 0024. Convolution Low Pass FilteringUploaded byAriel Lenis

- lec04_rquicksortUploaded byIsmail Abdullah Ozogur
- 2020 10 Sp Mathematics StandardUploaded byJYOTI YADAV
- Quadratic EquationUploaded bykristy66
- CSIR AnalysisUploaded byசெபா செல்வா
- bilangan real.pdfUploaded byRian Djatmoko
- Tips for Beginners for the TI 89 CalculatorUploaded bysjpark24
- Data Structures Lab ManualUploaded byhakkem b
- 7_4528_BorcinovaUploaded bySyifani Rahmania
- GraphUploaded byAnjam Chaudhary
- Free Pre-Algebra WorksheetsUploaded bySunny Mbaska
- ch04.pptUploaded byiamthe11
- DerivationsUploaded byRaja Gopal A
- Intro to the Theory of ComputationUploaded byAhmad Alhour
- Methods of Theoretical PhysicsUploaded byAnton Perkov
- course-info-matedht233.docUploaded byMuhammad Ｉｋｍａｌ
- 08 02 Euler MethodUploaded byJohn Bofarull Guix
- ShearingUploaded byRiya Singh
- Elementary AlgebraUploaded byDina Zafarraya
- Section01 - IntegersUploaded byyrazs8021
- mc annealing reportUploaded byapi-247505132
- Second course in linear algebraUploaded byJames King
- Language of Mathematics Narrative ReportUploaded byLowel Payawan
- 245057Uploaded bymari_eu
- 137302501-xii-mathematics-2-phpapp01.pdfUploaded byTheencyclopedia
- 9-12 Math OverviewUploaded byMedford Public Schools and City of Medford, MA
- Unit - Binary OperationsUploaded byavaquizzer
- GATE CLOUD_Signals and Systems by R K KanodiaUploaded byAmit1504
- Definite Integration IIUploaded byNamita Dash
- _b66323d90964cccb91c92f77bcb02ab0_codingAssign1Uploaded byIssam Sembati
- MAHARAJA RANJIT SINGH ARMED FORCES math.docxUploaded byAashish Aggarwal

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.