Spoj problem

Revision en4, by Taan, 2017-09-21 16:04:40

I try this problem on spoj but I get TLE. Someone can help me?

We have a m*n matrix of integer [0,2] and John are currently at the upper left position (row 1, column 1) and he want to come row m column n. He can travel right, left, toward the top, or toward the bottom of the grid. He can not travel on a diagonal. But John only love 0 and 1 so that he decide to chose the path which only have 0,1 and he want to his path is maximum value in decimal. John need your help!

Input:

Line 1: contain two integer m,n.

Line 2..m+1: Each line contains n integers.

Output:

The path which is maximum in decimal

(The input certain that John can come to row m column n)

Example:

Input:

3 5

0 1 2 0 2

0 1 0 0 1

1 2 1 2 1

Output :

0110011

You can sumbit solution here

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Taan 2017-09-21 16:04:40 1 Tiny change: ' TLE. Some one can he' -> ' TLE. Someone can he'
en3 English Taan 2017-09-21 12:46:31 0 (published)
en2 English Taan 2017-09-21 12:44:46 12 Tiny change: 'Example:\n 3 5\n\' -> 'Example:\n\nInput:\n\n 3 5\n\' (saved to drafts)
en1 English Taan 2017-09-21 12:43:08 876 Initial revision (published)