Connection Status:
Competition Arena > CovidCinema
2020 TCO Round 4 · 2020-04-13 · by misof · Greedy, Math
Class Name: CovidCinema
Return Type: String[]
Method Name: seat
Arg Types: (int, int, int, int)
Problem Statement

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.

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
0)
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...

1)
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'.

2)
4
5
14
2
Returns: {"B.AAA", ".AAAA", "AAAA.", "AAA.B" }

B.AAA .AAAA AAAA. AAA.B

3)
5
5
17
4
Returns: {"AAAAA", "AAAAA", "..AAA", "BB.AA", "BB.AA" }

AAAAA AAAAA ..AAA BB.AA BB.AA

4)
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.

Coding Area

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

Submitting as anonymous