Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Rat In A Labyrinth Problem Description Jenny is in the process of creating a unique cardboard labyrinth composed of various room - like structures, all

Rat In A Labyrinth
Problem Description
Jenny is in the process of creating a unique cardboard labyrinth composed of various room-like structures, all made from cardboard pieces. Her objective is to ensure that the entrances to these rooms are exclusively positioned along the outer edges of the labyrinth.
To begin, Jenny starts with a rectangular piece of cardboard with dimensions "m" units in length and "n" units in height. She also has several straight cardboard pieces at her disposal. Jenny's plan is to insert these cardboard pieces inside the rectangular cardboard in a manner that each inserted piece runs parallel to one of the rectangle's sides. This arrangement will form distinct room-like structures within the labyrinth. Jenny prefers rooms that have precisely four sides, and she designs her labyrinth with such rooms exclusively. Once the labyrinth is complete, Jenny is eager to play with it and decides to place her pet rat inside for a playful adventure. Now, she aims for finding the percentage probability of the rat successfully exiting the labyrinth rounded to the nearest integer value.
Given that the lower-left corner of the labyrinth is situated at coordinates (0,0) within quadrant one, and with knowledge of the labyrinth's length, height, the placement of straight cardboard pieces within it, print the percentage probability of the rat successfully exiting the labyrinth rounded to the nearest integer value.
Note : It is assured that the lines are valid and unique.
Constraints
0<= x1, x2, y1, y2<=100
0<= m,n <=100
Input
First line consists of two space separated integers, m and n denoting the length and height of the cardboard box.
Second line consists of an integer T, denoting the number of straight card board pieces that are inserted in the cardboard box as stated above.
Next T lines will have 4 integers denoting the starting and ending points of the straight cardboard pieces where they are placed. First two integers denotes (x1,y1) and the next two denotes (x2,y2).
Output
Print the percentage probability of the rat successfully exiting the labyrinth rounded to the nearest integer value.
Time Limit (secs)
1
Examples
Example 1
Input
44
5
1013
0343
1222
2023
1121
Output
67
Explanation
If we visualize the the above labyrinth, it will be like below.
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@7c351808:image1.png
The given lines divides the cardboard into 6 parts among which 2 parts have no entrance. Thus escape rate of rat from the labyrinth will be number of rooms from which rat can exit)/(total number of rooms)*100 i.e.,(4/6)*100 which is (0.66666..)*100=66.666.., which on rounding off to the nearest integer will be 67.
Example 2
Input
34
3
1014
2124
1131
Output
100
Explanation
If we visualize the the above labyrinth, it will be like below.
com.tcs.cv.automata.ei.middleware.DocxToHtmlConverter@7c351808:image2.png
The given lines divides the cardboard into 4 parts and all parts have entrance. Thus escape rate of rat from the labyrinth will be number of rooms from which rat can exit)/(total number of rooms)*100 i.e.,(4/4)*100 which is (1)*100=100, which on rounding off to the nearest integer will be 100.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago