SimplestCrossword
SRM 793 · 2020-11-03 · by misof
Problem Statement
You are given two
Return the crossword as a
Constraints
- H will contain between 2 and 10 characters, inclusive.
- V will contain between 2 and 10 characters, inclusive.
- Each character in H and V will be an uppercase English letter ('A'-'Z').
"TOP"
"CODER"
Returns: {".C.", "TOP", ".D.", ".E.", ".R." }
This is what the return value looks like when formatted into a rectangle: {".C.", "TOP", ".D.", ".E.", ".R." } This return value describes the following crossword: .C. TOP .D. .E. .R. In this particular test case, this is the only valid solution.
"CODER"
"TOP"
Returns: {".T...", "CODER", ".P..." }
Here we swapped the two words, so now CODER should go horizontally. The returned crossword looks as follows: .T... CODER .P...
"AAAAA"
"AAAAAA"
Returns: {"...A.", "...A.", "...A.", "AAAAA", "...A.", "...A." }
Returned crossword: ...A. ...A. ...A. AAAAA ...A. ...A. In this case there are 29 other valid crosswords, and each of those would be accepted as well.
"CAT"
"DOG"
Returns: { }
We cannot make these two words overlap.
"FZUHE"
"DYVBX"
Returns: { }
Submissions are judged against all 96 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class SimplestCrossword with a public method vector<string> construct(string H, string V) · 96 test cases · 2 s / 256 MB per case