All submissions for this problem are available.
This is an interesting game. In Lovely college, there are number of blocks. All blocks are arranged in the form of a nXn square.
Master server in ith row and jth column is represented as server[i][j] starting from server upto last master server i.e. server[n-1][n-1].
Each block contains computer labs. All the labs contain different number of computers. All the labs have been hacked. Hackers have changed the passwords of all the computers. There is a master server in each block. Unlocking each password will take a lot of time. So simple task is to somehow reach server[n-1][n-1] unlocking all passwords on the way. You need to start from server.From server[i][j], you can either move to server in next column( server[i][j+1]) or server in next row server[i+1][j].
On unlocking the master server of the block containing C[i][j] number of computers, you get points equal to number of 1s in C[i][j] at odd positions in binary representation of C[i][j]. Position will be counted taking rightmost position as 1.
Odd positions in any number m are all the positions starting from rightmost bit of m. i.e. position 1,3,5 and so on.
You need to calculate maximum number of points you can get in a particular arrangement. You will be provided with n (where nXn are total number of blocks) and number of computers in each block.
First line contains number of test cases.
Each test case which follows is as follows.
First line contains an integer n.
Each of the following n lines contains n integers representing number of computers in each block i.e. in the form of a matrix.
For each of the testcase output maximum possible points(if max points > 0) which can be earned in this game. If maximum possible points are 0 then output “BAD LUCK” for that particular test case
Input: 2 2 0 0 0 0 2 3 15 2 33 Output: BAD LUCK 4 Constraints 1<=t<=10 1<=n<=500 0<=No. of computers in a block<=10000
|Time Limit:||0.124444 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, 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, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.