Canadian Computing Competition: 2003 Stage 1, Junior #5, Senior #3
The floor plan of a house shows rooms separated by walls. This floor plan can be transferred to a grid using the character I
for walls and .
for room space. Doorways are not shown. Each I
or .
character occupies one square metre.
In this diagram, there are six rooms.
You have been given the floor plan of a house and a supply of hardwood flooring. You are to determine how many rooms will have the flooring installed if you start installing the floor in the largest room first and move to the next largest room, and so on. You may not skip over any room, and you must stop when you do not have enough wood for the next room. Output the number of rooms that can have hardwood installed, and how many square metres of flooring are left over. No room will be larger than square metres.
The first line contains the number of square metres of flooring you have. The second line contains an integer in range that represents the number of rows in the grid. The third line contains an integer in that represents the number of columns in the grid. The remaining lines contain characters of grid data.
Sample Input 1
105
14
16
IIIIIIIIIIIIIIII
I......I.......I
I......III.....I
I........I.....I
I........IIIIIII
IIIIIIIIII.....I
I.I......I.....I
III..III.I.....I
I....I.IIIII...I
I....I.....III.I
I....I.......I.I
I....I.....III.I
I....I.....I...I
IIIIIIIIIIIIIIII
Output for Sample Input 1
4 rooms, 1 square metre(s) left over
Sample Input 2
13
2
3
.I.
.I.
Output for Sample Input 2
2 rooms, 9 square metre(s) left over
Comments
when ccc is hosted in Quebec:
Be sure to remember that the judge is strict so your output should be exact. This includes not spelling "metre" as "meter" like I did.
If you have this map,
is it one room or two?
There are 2 rooms.
This comment is hidden due to too much negative feedback. Show it anyway.
The statement implies that a room does not have diagonal walls, and in a real-world scenario you can't move between cracks in walls anyways.
Should we print 0 meters left over?
Never mind, there aren't any such cases it seems
What would you do if there is 0 flooring left over?
This comment is hidden due to too much negative feedback. Show it anyway.
If there is only 1 room, "rooms" should not be pluralized.
Also seems that if no rooms can have the floor installed, rooms should be pluralized.
This should seriously be in the problem statement
Thanks for the hint.