TapeMeasure
SRM 789 · 2020-08-28 · by misof
Problem Statement
Here's the beginning of an ASCII art bitmap that depicts a tape measure:
################################################### # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 0 10 20
A more formal description:
- The first row is full of '#' marks and represents the top edge of the tape measure.
- The second row shows unit marks in every second column.
- Multiples of five get a longer mark that continues into the third row.
- Multiples of ten get a mark that reaches all the way into the fourth row, and they also get labels in the fifth row. The label always begins in the column with the mark and extends to the right as needed.
You are given the
Constraints
- leftMark will be between 0 and 999, inclusive.
- rightMark will be between leftMark and 999, inclusive.
- rightMark - leftMark will be at most 25.
0
25
Returns: {"###################################################", "# # # # # # # # # # # # # # # # # # # # # # # # # #", "# # # # # #", "# # # ", "0 10 20 " }
This is the exact example shown in the problem statement.
981
990
Returns: {"###################", "# # # # # # # # # #", " # #", " #", "0 9" }
Note how the labels for marks 980 and 990 are partially visible in this section of the tape measure. Below we show a section of the tape measure that is one mark wider on each side (left=980, right=991) so that you can see these labels completely. ####################### # # # # # # # # # # # # # # # # # 980 990
20
20
Returns: {"#", "#", "#", "#", "2" }
31
38
Returns: {"###############", "# # # # # # # #", " # ", " ", " " }
64
75
Returns: {"#######################", "# # # # # # # # # # # #", " # # #", " # ", " 70 " }
Submissions are judged against all 107 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TapeMeasure with a public method vector<string> draw(int leftMark, int rightMark) · 107 test cases · 2 s / 256 MB per case