You are going to hold an international programming contest in a rectangular hall, which has
A set of seats in the hall
is exactly the set of all seats such that and .
A rectangular set consisting of
After preparing your seating chart, you receive several requests to swap two seats assigned to two contestants.
More precisely, there are
Implementation Details
You should implement the following procedure and function:
void give_initial_chart(int H, int W, std::vector<int> R, std::vector<int> C)
: the number of rows and the number of columns. : arrays of length representing the initial seating chart.- This procedure is called exactly once, and before any call to
swap_seats
.
int swap_seats(int a, int b)
- This function describes a request to swap two seats.
: contestants whose seats are to be swapped.- This function is called
times. - This function should return the beauty of the seating chart after the swap.
Example
Let
The grader first calls give_initial_chart(2, 3, [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 2, 2])
.
At first, the seating chart is as follows.
Let's say the grader calls swap_seats(0, 5)
.
After the request
The sets of seats corresponding to the contestants swap_seats
should return
Let's say the grader calls swap_seats(0, 5)
again.
After the request swap_seats
should return
The files sample-01-in
and sample-01-out
in the zipped attachment package correspond to this example.
Other sample inputs/outputs are also available in the package.
Constraints
for any call toswap_seats
for any call toswap_seats
for any call toswap_seats
Subtasks
- (
points) , - (
points) , - (
points) , , - (
points) , for any call toswap_seats
- (
points) - (
points) No additional constraints
Sample Grader
The sample grader reads the input in the following format:
- line
: - line
: - line
:
Here, swap_seats
for the request
The sample grader prints your answers in the following format:
- line
: the return value ofswap_seats
for the request .
Attachment Package
The sample grader along with sample test cases are available here.
Comments