CovidCinema
2020 TCO Round 4 · 2020-04-13 · by misof
Problem Statement
You are running a cinema. The auditorium is a rectangular array of seats with R rows and C columns in each row.
Due to the Covid-19 regulations, people who are not a part of the same group are not allowed to sit next to each other, nor immediately behind each other.
Two groups of people would like to see the same movie. There are A people in the first group and B people in the second group.
If it is impossible to seat all those people according to the regulations, return an empty
Constraints
- R will be between 1 and 50, inclusive.
- C will be between 1 and 50, inclusive.
- A will be between 1 and R*C, inclusive.
- B will be between 1 and R*C, inclusive.
4
6
2
3
Returns: {"......", ".A..BB", "......", "B.A..." }
A rather large cinema and very few people. We have many ways to place them. The example one is shown below in a nicer format: ...... .A..BB ...... B.A...
4
5
13
7
Returns: { }
These two groups would fill the cinema completely, and that's not possible without some 'A' being adjacent to some 'B'.
4
5
14
2
Returns: {"B.AAA", ".AAAA", "AAAA.", "AAA.B" }
B.AAA .AAAA AAAA. AAA.B
5
5
17
4
Returns: {"AAAAA", "AAAAA", "..AAA", "BB.AA", "BB.AA" }
AAAAA AAAAA ..AAA BB.AA BB.AA
1
2
1
1
Returns: { }
Submissions are judged against all 211 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CovidCinema with a public method vector<string> seat(int R, int C, int A, int B) · 211 test cases · 2 s / 256 MB per case