0% found this document useful (0 votes)
6 views4 pages

Flood Damage Assessment for Bibi's House

Uploaded by

xandertrevor273
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Flood Damage Assessment for Bibi's House

Uploaded by

xandertrevor273
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

E

COMP6047 – Algorithm and Programming

T
T
NO
BU
Flood at Bibi’s House
Every rainy season, Bibi always confused because she has a water hole on her house wall.
When it rains, water starts to fill her house. For your information, Bibi is a person who
really likes cleanliness (and she also very rich). So after the flood recedes, Bibi will replace
all floors (tiles) affected by the flood water.

RI
O
Inside Bibi’s house there are only 3 things:

• Wall (#) in Bibi’s house can not be passed by the water.


T
• On the floor (.), the water can move up, down, left, and right.
D

• Water Source (S) where water enters Bibi’s house. The water source can spread to
S
4 directions: up, down, left and right.

As a friend of her, she ask you to count the number of floors (tiles) to be replaced. For
DI

your information, where water enters the house (S) is not a floor.

You are encouraged to use recursive techniques to solve this problem.


OT
UT
RE

Format Input
Input consists of T , the number of testcases. For each case, there are N, M , number of
rows and columns in her house plan. Then, N lines followed which consist of M characters
describing her house plan information.
N
IB
Format Output
Output should be expressed in format “Case #X: Y” - X is number of floors (tiles) to be
replaced in X th case.
TR
DO

Constraints
• 1 ≤ T ≤ 10

• 1 ≤ N, M ≤ 100
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
Sample Input (standard input)

NO
BU
2
5 5
#####
#S..#
###.#
#...#

I
#####
2 2

R
O
S.
.#
T
D

Sample Output (standard output)


S
Case #1: 6
Case #2: 2
DI

OT
UT
RE

N
IB
TR
DO
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
NO
BU
Flood at Bibi’s House
Ketika musim hujan tiba, Bibi kebingungan untuk menutup lubang di tembok rumahnya.
Air hujan dari atap pun masuk ke dalam rumahnya dengan segera. Bibi adalah seorang
yang sangat suka akan kebersihan dan sangat kaya, maka setelah banjir surut, Bibi akan
mengganti semua lantai / keramik yang terkena banjir.

RI
O
Pada rumah Bibi hanya terdapat 3 hal:

• Tembok (#) pada rumah Bibi tidak dapat dilalui oleh air.
T
• Pada lantai (.), air dapat bergerak ke atas, bawah, kiri, dan kanan.
D

• Sumber air (S) merupakan tempat air masuk ke rumah Bibi. Sumber air dapat
S
menyebar ke 4 arah: atas, bawah, kiri, dan kanan.

Sebagai teman Bibi, anda diminta untuk membantu Bibi menghitung banyaknya lantai
DI

yang akan diganti. Perlu diketahui, tempat masuknya air (S) bukanlah sebuah lantai.

Anda disarankan untuk menggunakan teknik rekursif untuk menyelesaikan


masalah ini.
OT
UT
RE

Format Input
Input terdiri dari 1 buah angka bulat T yang menyatakan jumlah testcase. Pada tiap
kasus, terdapat N, M , banyak baris dan kolom pada denah rumah Bibi. Kemudian, untuk
N
IB
N baris berikutnya terdapat M karakter yang menggambarkan karakteristik denah rumah
Bibi.

Format Output
TR
DO

Output yang dikeluarkan dalam format “Case #X: Y” - X merupakan nomor testcase
dan Y merupakan jumlah lantai/keramik yang harus diganti oleh Bibi pada kasus ke X.

Constraints
• 1 ≤ T ≤ 10
IS

• 1 ≤ N, M ≤ 100
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.
E
COMP6047 – Algorithm and Programming

T
T
Sample Input (standard input)

NO
BU
2
5 5
#####
#S..#
###.#
#...#

I
#####
2 2

R
O
S.
.#
T
D

Sample Output (standard output)


S
Case #1: 6
Case #2: 2
DI

OT
UT
RE

N
IB
TR
DO
IS
ED

© School of Computer Science - BINUS, 2021. No part of the materials available may be copied,
photocopied, reproduced, translated, or reduced to any electronic medium or machine-readable form,
in whole or in part, without prior written consent of School of Computer Science - BINUS. Any other
reproduction in any form without the permission of School of Computer Science - BINUS is probihited.
Violators of this clause may be academically sanctioned.

Common questions

Powered by AI

Exceeding the allowed constraints of N and M would lead to scenarios that the designed algorithm may not be equipped to handle, potentially causing memory overflows, increased computational requirements, and inability to deliver timely and accurate results. Algorithms designed under specific constraints are often optimized for those conditions .

The water can move from the source location 'S' up, down, left, and right through the floor segments represented by '.' but cannot pass through walls represented by '#'. This means the water can only propagate to adjacent tiles that are not blocked by walls .

The input format specifies a series of test cases, each beginning with two integers, N and M, followed by N lines of strings representing the house layout. Output is provided in the format “Case #X: Y” where X is the test case number and Y is the calculated answer for that specific case. This structured approach ensures clarity and consistency across multiple test cases .

Recursion is recommended due to its natural fit for problems involving exploration from a source point based on defined movement rules, such as flooding simulations. By recursively visiting each accessible tile from the water source, it simplifies the process of counting all the tiles that would be affected by the flood in a structured and efficient manner .

Identifying the position of 'S' is crucial as it determines the starting point for water propagation. From 'S', water expands to adjacent floor tiles ('.'). This initial position dictates the potential spread of water and hence the number of tiles affected, which directly impacts the calculation of how many floor tiles need replacement .

The problem enforces restrictions by explicitly prohibiting reproduction or redistribution in any form without consent from the School of Computer Science - BINUS. This is likely important to protect intellectual property, ensure academic integrity, and control the distribution of educational material .

The constraints are that the number of test cases T must satisfy 1 ≤ T ≤ 10, and for each case, the dimensions of the house layout, represented by N (rows) and M (columns), must meet 1 ≤ N, M ≤ 100 .

Accounting for all flood-affected floors ensures an accurate assessment of damage, which is necessary for effective restoration and prevention of hygiene issues. Overlooking areas might lead to inadequate repairs and persistent problems, emphasizing the importance of a comprehensive check .

Cleanliness is a significant factor because Bibi's preference for a clean environment leads her to replace all tiles affected by floodwater. Her prioritization of hygiene drives her to take corrective actions promptly after the flood recedes .

Computational constraints such as size of N and M affect the complexity and resource requirements (time and space complexity) for processing each test case. As problem size increases, algorithms designed without considering scalability may struggle, potentially leading to incorrect outputs or increased execution time. Therefore, understanding and planning for these constraints is key to designing efficient solutions .

You might also like