#K35697. Theater Seating Reservation Checker
Theater Seating Reservation Checker
Theater Seating Reservation Checker
You are given several test cases representing seat reservations in a theater with a specified number of rows and columns. Each reservation specifies a seat using its row and column numbers. A reservation conflict occurs if the same seat is reserved more than once in a single test case.
Your task is to determine whether all reservations in each test case can be accommodated without conflict. If any seat is reserved multiple times, output Conflict
. Otherwise, output Success
.
The process for each test case is as follows:
- Read the dimensions of the theater: the number of rows (R) and columns (C).
- Read the number of reservations, N.
- For each reservation, a pair of numbers (r, c) is provided indicating the seat.
A conflict happens if there exist two indices i and j (with i ≠ j) such that the reservation coordinates satisfy \( (r_i, c_i) = (r_j, c_j) \).
Formally, let \( S = \{(r_k, c_k) : 1 \leq k \leq N\} \). The outcome is defined as:
[ \text{Result} = \begin{cases} Success, & \text{if } |S| = N,\ Conflict, & \text{if } |S| < N. \end{cases} ]
inputFormat
The input is provided via standard input and has the following format:
T R C N r1 c1 r2 c2 ... (N reservations) ... (Repeat for each of T test cases)
Where:
- T is the number of test cases.
- R and C are the number of rows and columns in the theater.
- N is the number of reservations for that test case.
- Each reservation is provided as two integers r and c representing the row and column.
outputFormat
For each test case, output a single line containing either Success
or Conflict
(without quotes) indicating whether all reservations are free of conflicts.
If there are T test cases, the output should contain T lines, one for each test case in the order they were given.
## sample1
3 3
2
1 2
2 2
Success
</p>