Answered step by step
Verified Expert Solution
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 roomlike 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 roomlike 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 lowerleft corner of the labyrinth is situated at coordinates 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
x x y y
mn
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 integers denoting the starting and ending points of the straight cardboard pieces where they are placed. First two integers denotes xy and the next two denotes xy
Output
Print the percentage probability of the rat successfully exiting the labyrinth rounded to the nearest integer value.
Time Limit secs
Examples
Example
Input
Output
Explanation
If we visualize the the above labyrinth, it will be like below.
com.tcscvautomata.eimiddleware.DocxToHtmlConverter@c:imagepng
The given lines divides the cardboard into parts among which parts have no entrance. Thus escape rate of rat from the labyrinth will be number of rooms from which rat can exittotal number of rooms ie which is which on rounding off to the nearest integer will be
Example
Input
Output
Explanation
If we visualize the the above labyrinth, it will be like below.
com.tcscvautomata.eimiddleware.DocxToHtmlConverter@c:imagepng
The given lines divides the cardboard into parts and all parts have entrance. Thus escape rate of rat from the labyrinth will be number of rooms from which rat can exittotal number of rooms ie which is which on rounding off to the nearest integer will be
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started