#C1290. Find Consecutive Available Seats

    ID: 42378 Type: Default 1000ms 256MiB

Find Consecutive Available Seats

Find Consecutive Available Seats

You are given a seating plan for a theater in the form of a matrix with R rows and S seats per row. Each seat is either available (0) or booked (1). Given an integer G representing the size of a group, your task is to determine the first block of G consecutive available seats in any row.

The search is performed row by row from top to bottom, and within each row from left to right. If such a block exists, output the row number and the starting seat index (both 0-indexed). Otherwise, print Not Available.

In mathematical terms, let the seating matrix be \( A \) where \( A_{i,j} \) is either 0 (available) or 1 (booked). Find the smallest \( i \) and \( j \) such that \( A_{i,j} = A_{i,j+1} = \cdots = A_{i,j+G-1} = 0 \). If no such indices exist in any row, output Not Available.

inputFormat

The first line of the input contains three integers: R (number of rows), S (number of seats per row), and G (group size), separated by spaces.

The next R lines each contain S integers (either 0 or 1), representing the seating plan for that row.

outputFormat

If a valid block of consecutive available seats is found, output two integers: the row number and the starting seat index, separated by a space. If no such block exists, output Not Available.

## sample
4 5 3
0 0 0 1 0
1 0 0 0 0
1 1 0 0 0
0 0 0 0 0
0 0