Posts

Showing posts with the label long challenge

Codechef Operations in a matrix

/* Sakshi had a matrix with  N N  rows (numbered  1 1  through  N N ) and  M M  columns (numbered  1 1  through  M M ). Initially, all cells of this matrix contained  0 0 -s. Let's denote a cell in row  r r  and column  c c  by  ( r , c ) ( r , c ) . Sakshi is well-known for troubling others. This time, her friends Nikki and Mansi planned to take revenge and teach her a lesson, so they changed her matrix by performing the following operation  Q Q  times: Choose any valid cell  ( x , y ) ( x , y ) . Add  1 1  to all the cells in row  x x . Add  1 1  to all the cells in column  y y . For each valid  i i , the cell chosen in the  i i -th operation was  ( X i , Y i ) ( X i , Y i ) . Nikki and Mansi challenged Sakshi to find the number of cells in the resulting matrix which contain odd integers. Sakshi is not good at math, since she has spent...