Posts

Showing posts from January, 2016

【UVa】1600 – Patrol Robot

Image
題目內容 A robot has to patrol around a rectangular area which is in a form of  m   x   n  grid ( m  rows and  n columns). The rows are labeled from 1 to  m . The columns are labeled from 1 to  n . A cell  ( i ,  j ) denotes the cell in row i  and column  j  in the grid. At each step, the robot can only move from one cell to an adjacent cell, i.e. from  ( x ,  y )  to  ( x  + 1,  y ) ,  ( x ,  y  + 1) ,  ( x  – 1,  y )  or  ( x ,  y  – 1) . Some of the cells in the grid contain obstacles. In order to move to a cell containing obstacle, the robot has to switch to turbo mode. Therefore, the robot cannot move continuously to more than  k  cells containing obstacles. Your task is to write a program to find the shortest path (with the minimum number of cells) from cell (1, 1) to cell  ( m ,  n ) . It is assumed that both these c...