FloorLayout
SRM 383 · 2007-12-13 · by StevieT
Problem Statement
You are building a house and are about to lay the floorboards in a particular room. Your architect has designed the layout of the floorboards and you now want to know how many boards you need to buy. Each board is 1 unit wide and can be of any positive integer length. The room is rectangular and the boards are to be laid out on a unit-square grid inside the room, parallel to the walls of the room.
You are given a
Constraints
- layout will contain between 1 and 50 elements, inclusive.
- Each element of layout will contain between 1 and 50 characters, inclusive.
- Each element of layout will contain the same number of characters.
- Each character in layout will be a '-' or a '|'.
{"----"
,"----"
,"----"
,"----"}
Returns: 4
This layout contains 4 boards laid east/west.
{"-||--||--"
,"--||--||-"
,"|--||--||"
,"||--||--|"
,"-||--||--"
,"--||--||-"}
Returns: 31
This is an aesthetic pattern made up of boards of lengths 1 and 2.
{"--------"
,"|------|"
,"||----||"
,"|||--|||"
,"||----||"
,"|------|"
,"--------"}
Returns: 13
{"||-||-|||-"
,"||--||||||"
,"-|-|||||||"
,"-|-||-||-|"
,"||--|-||||"
,"||||||-||-"
,"|-||||||||"
,"||||||||||"
,"||---|--||"
,"-||-||||||"}
Returns: 41
{"-||--|"
,"||||||"
,"|||-|-"
,"-||||-"
,"||||-|"
,"||-||-"}
Returns: 19
Submissions are judged against all 62 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FloorLayout with a public method int countBoards(vector<string> layout) · 62 test cases · 2 s / 256 MB per case