Taan's blog

By Taan, history, 7 years ago, In English

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

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it

By Taan, history, 7 years ago, In English

If I have a set( priority queue) <C++ stl> can I know the middle element of that set (priority queue) in O(log) ?

Full text and comments »

  • Vote: I like it
  • -14
  • Vote: I do not like it