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 String[]. Otherwise, return any one possible seating plan: a String[] with R elements, each containing C characters. Use 'A' for people from the first group, 'B' for people from the second group, and '.' for empty seats.
Definition
- Class:
- CovidCinema
- Method:
- seat
- Parameters:
- int, int, int, int
- Returns:
- String[]
- Method signature:
- String[] seat(int R, int C, int A, int B)
- (be sure your method is public)
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.
Examples
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.B5
5
17
4
Returns: {"AAAAA", "AAAAA", "..AAA", "BB.AA", "BB.AA" }AAAAA AAAAA ..AAA BB.AA BB.AA