#K74722. Find the K-th Seat in a Classroom

    ID: 34261 Type: Default 1000ms 256MiB

Find the K-th Seat in a Classroom

Find the K-th Seat in a Classroom

You are given a classroom represented as an M x N grid. The first child will always sit at the top-left corner (i.e. cell \((0,0)\)). Each subsequent child occupies the nearest available seat based on a breadth-first search order, which can be understood as increasing Manhattan distance from the initially occupied seat. In case of a tie, the seat with the smallest row number is chosen, and if the tie persists, the seat with the smallest column number is selected.

Your task is to determine the coordinates of the seat occupied by the \(K\)-th child.

Note: The seating order is determined by performing a breadth-first search (BFS) on the grid starting from cell \((0,0)\), and exploring neighbors in the following order: up, down, left, then right.

Formally, let \(\text{seat}_i\) denote the coordinates \((r_i, c_i)\) of the \(i\)-th child. You need to compute \(\text{seat}_K\).

inputFormat

The input is provided via standard input and consists of a single line containing three integers \(M\), \(N\), and \(K\) separated by spaces. \(M\) and \(N\) represent the number of rows and columns in the grid, respectively, and \(K\) indicates the sequence number of the child.

outputFormat

Output two space-separated integers \(r\) and \(c\) which represent the row and column of the seat taken by the \(K\)-th child, respectively. The output should be written to standard output.

## sample
3 4 5
1 1

</p>