23 views

Uploaded by Ariel Lenis

- BGP Divergence
- M30 Inventing a Formula for Arithmetic Sequences - PgSeqSer2
- P3_C11
- final2
- 1.7_Transformations.pdf
- Social Network Analysis.pdf
- 031006_1
- Azure Cosmos Db 2-Cheat Sheet v4-Letter
- Poly
- Predicting New Collaborations in Academic Citation Networks of IEEE and ACM Conferences
- Samsung New
- Lecture on Advanced Mathematical Technques
- lec not
- Route Planning
- Miki Shimabara
- logimath round1 questions
- maths
- SolutionCT 2 NCS303.Docx
- 18 Topo Sort
- Trigonometria Richard

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

- BGP DivergenceUploaded byapi-3761983
- M30 Inventing a Formula for Arithmetic Sequences - PgSeqSer2Uploaded byNora
- P3_C11Uploaded byAnonymous lFoNf51pnf
- final2Uploaded byJohn Wayne
- 1.7_Transformations.pdfUploaded byRashid Davis
- Social Network Analysis.pdfUploaded bygeorgewbush
- 031006_1Uploaded byAdnan Ahmed
- Azure Cosmos Db 2-Cheat Sheet v4-LetterUploaded byStewart Henderson
- PolyUploaded byfonseca_r
- Predicting New Collaborations in Academic Citation Networks of IEEE and ACM ConferencesUploaded bySaad
- Samsung NewUploaded bytutamasdfghjkl
- Lecture on Advanced Mathematical TechnquesUploaded byDebayan Gupta
- lec notUploaded bystacy
- Route PlanningUploaded by4gen_3
- Miki ShimabaraUploaded byjaesalazarca
- logimath round1 questionsUploaded byapi-388519772
- mathsUploaded bySasi Kiran S
- SolutionCT 2 NCS303.DocxUploaded byKartikay Sharma
- 18 Topo SortUploaded bysangtao
- Trigonometria RichardUploaded byRichy Ricardo
- JEE Main 2017 Solution Paper 1 Code DUploaded byShivamKumar
- 363-1483-1-PBUploaded byPalanivel Kasilingam
- Counting Integral SolutionsUploaded byOMSURYACHANDRASIVA
- img 20140710 0001Uploaded byapi-258897284
- GRE Syllabus 2011 Test Exam General SubjectUploaded bySathiya Moorthy
- Fourier SeriesUploaded byAriesFranandaPanjaitan
- 2 2 domain and range pdf for onlineUploaded byapi-234934912
- logMSUploaded byjsarmientodc
- Ausmatolwajoq a 05Uploaded byBambang Suhono
- Algebra ProblemsUploaded byAkash Aggarwal

- Carta Convocatoria de InvetigacionJICCTBOLUploaded byAriel Lenis
- CUDNN Library (1)Uploaded byAriel Lenis
- CUDNN Library (1)Uploaded byAriel Lenis
- Práctica Recuperación Evaluación Final_864Uploaded byAriel Lenis
- Standard Music Notation PracticeUploaded byfakhribabiker
- Fairy TaleUploaded byAriel Lenis
- Developer's Guide to Microsoft Enterprise Library - 2nd EditionUploaded bymanavsharma
- Unidad 3 Aritmetica de Las asUploaded byjp0987
- qosmio_X875-Q7390Uploaded byFernando Mori
- Serie Asincrona en CUploaded byAlejandro Guzmán
- Lista Precios 2012 SoElUploaded byAriel Lenis
- Análisis discreto de FourierUploaded byMaria Gabriela Ventura Abreu
- Numero 18Uploaded byAriel Lenis
- LM35 Temperature SensorUploaded byapi-3799604
- 2011. 0024. Convolution Low Pass FilteringUploaded byAriel Lenis
- the physics of music by David R. LappUploaded bydomakana
- 207.pdfUploaded byAriel Lenis
- PS2-VGAUploaded byAdnan Hayat

- DWM AssignmentUploaded byPhonte Dalitso Chaguluka
- JORCUploaded bykeeoponmovin
- CST CABLE STUDIO - Workflow and Solver OverviewUploaded byteomondo
- City RelinkUploaded byKent State University Cleveland Urban Design Collaborative
- Values StatementsUploaded byfcsnyder
- DOBLE SFRA Quick Start GuideUploaded byPaulRueda
- july1999-p80Uploaded bychocobon_998078
- Use Case Realization DocumentUploaded byLuis Andrés Villavicencio Pérez
- DAFTAR PUSTAKAUploaded byAnantya Sophan
- THE PIPIT BIRD AND THE KING.docxUploaded byVijayRaggu
- Colorqube 8570 8870 Error Code ListUploaded byewrenchcole_60210010
- Final Exam Ccna 2 RoutingUploaded bytamara_v
- Unit Plan for Electricity and MagnetismUploaded bydela2
- Lenovo p50 4 Ram 16gb Total 64gb 1 Sata 2 m2 Ssd Max 3 OsUploaded byChua Hian Koon
- SidebySide1_Workbook_sampleunit.pdfUploaded byDan Franlui Mayo
- Mm CodesUploaded byXuhair Ahmed
- Tratamiento Antinflamatorio Con Colchicina en Infarto Agudo Al MiocardioUploaded byBPMC
- Contoh AnnouncementUploaded byyunus
- Steel RulesUploaded byxant_san9044
- symmetry-6-28-09Uploaded bydgagan22
- Medications CompleteUploaded byPaolo Zabat
- HTML L21Uploaded bydibbasearch
- QStart Flatpack2-PSSystUploaded byTERASAT SA
- Speech 552Uploaded byRitwik Priya
- iron_inox_provapor_©_Uploaded bypukymotto
- Big Band Bass John Clayton 1Uploaded byAdonay C. Ubaldo Ramos
- UT Dallas Syllabus for rhet1101.025.07f taught by John Jackson (johnja)Uploaded byUT Dallas Provost's Technology Group
- ASHRAE Guidelines and StandardsUploaded byMax Phillips
- Matt Hern. Everywhere All the TimeUploaded byandrehpv
- Australian Flying Saucer Review - Number 5 - July 1966Uploaded byUFO Research (NSW) Incorporated, Australia