BOOK MY SHOW

All submissions for this problem are available.
$K$ friends are going to watch a newly realeased movie $Miramar$ : $The$ $Snipers$ $Zone$ and they are booking tickets online. The theatre consists of $N$ rows of seats and each row contains $M$ seats where $M$ is odd. The rows are labelled as A B C ... Z ($N$<=26) where row A is nearest to the movie screen. The seats in any row are labelled as 1 2 3 ... $M$. Well, they have three conditions to select the $K$ tickets from any row. 1) All the seats should be contiguous. 2) All the seats should be in the farthest possible row from the movie screen. 3) All the seat numbers should be in the inclusive range of given $L$ and $R$. For the farthest row satisfying above three conditions, you have to select $K$ closest possible seats from the center seat of that row. If multiple closest possible selections are present in a row, choose the leftmost contiguous set of seats among all possible sets. i.e. Sum of the seat numbers should be minimum. (Refer explanation of Test Case 2 for clarity). Data of available seats is given to you in the form of $N$ x $M$ matrix of integers where $1$ indicates seat is booked and $0$ indicates seat is available. You have to tell which row they should book along with the seat numbers such that all conditions are satisfied. Print $1$ if it is impossible. $Note$: Center Seat of all N rows is always booked. ###Input:  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains three spaceseparated integers $N$, $M$ and $K$.  The second line of each test case contains two spaceseparated integers $L$ and $R$.  Next $N$ Lines contains $M$ spaceseparated integers either $0$ or $1$ which represents availability of seats from nearest row to the farthest row of the movie screen. ###Output: For each test case, print a single line containing one character — the label of selected row followed by $K$ spaceseparated integers  the seat numbers in selected row. If seat selection is impossible print a single integer $1$. ###Constraints  $1 \leq T \leq 10$  $1 \leq N \leq 26$  $1 \leq M \leq 10^3$  $1 \leq K \leq M$  $1 \leq L \leq M$  $1 \leq R \leq M$  Center Seat of all $N$ rows is always booked. ###Sample Input: 2 5 5 2 1 4 1 1 1 0 1 0 0 1 1 1 1 0 1 0 1 0 0 1 1 1 1 0 1 0 0 4 11 2 2 10 1 0 1 1 0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 1 0 0 ###Sample Output: D 1 2 C 4 5 ###EXPLANATION: Test Case 1 : ![Alt text](https://drive.google.com/uc?export=download&id=1PpUzFHYbfLFU8N0mO7MJgOBI...) This is the given seat availability. Valid rows to select seats are B and D. Out of these D is the farthest row from the screen. Therefore we select D 1 2 as shown below : ![Alt text](https://drive.google.com/uc?export=download&id=1zv7QBZt4l7X24LbHIr9K65v...) Test Case 2 : ![Alt text](https://drive.google.com/uc?export=download&id=1ee2FN1IrLF8inydcoLdG60BQ...) Valid rows to select seats are A, B and C. C is the farthest row. In row C, Contiguous and closest possible seats from the centre are {4,5} and {7,8}. Out of these two possible sets of 2 seats each, we select {4,5} because sum of seat numbers should be minimum if multiple closest possible selections from centre are present in a row i.e. Here, (4+5) < (7+8). Therefore we select C 4 5 as shown below : ![Alt text](https://drive.google.com/uc?export=download&id=1csgaOu9G1bSjT6jfAdJusSUw...)Author:  iamrohitrc 
Tags  iamrohitrc 
Date Added:  27072018 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions