TableLabel
TCO07 Round 1A · 2007-03-07 · by dgoodman
Problem Statement
X XX XXX ABC ABCX ABCXX ABCXXX D DX DXX DXXXThe problem is that we are given the table entries, but don't know what the row and column labels are. Given a
The i-th element of table will give the i-th row of the table (i=0 is the top row), with adjacent entries separated by one or more spaces. It may have leading or trailing spaces.
Constraints
- table will contain between 1 and 50 elements, inclusive.
- Each element of table will contain between 1 and 50 characters, inclusive.
- Each element of table will contain only spaces (' ') and uppercase letters ('A'-'Z').
- Each element of table will contain at least 1 entry.
- Each element of table will contain the same number of entries.
{" ABCX ABCXX ABCXXX ","DX DXX DXXX "}
Returns: {"X", "XX", "XXX", "ABC", "D" }
This is the example given above.
{"AAA AAA"," AAA AAA"}
Returns: {"multiple" }
The row labels could both be "A" and the column labels both be "AA", or the row labels could both be "AA" and column labels "A".
{"AB CD"}
Returns: {"none" }
If the row label could be empty we could label this table by giving the columns the labels "AB" and "CD", but that is not allowed.
{"ABCDEFG ABCDEFG ABCDEFG ABCDEFG ACDXX "}
Returns: {"BCDEFG", "BCDEFG", "BCDEFG", "BCDEFG", "CDXX", "A" }
{"ABCDEFGA","ACDXXA"}
Returns: {"A", "ABCDEFG", "ACDXX" }
Submissions are judged against all 74 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TableLabel with a public method vector<string> labels(vector<string> table) · 74 test cases · 2 s / 256 MB per case