• [1139] The Gluttonous Rat

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Everyone knows the greedy snake game.Now this problem is the same as it.In a room,the rat is seeking food.Food will appear one by one after the rat gets one food.Food will only appear in the blanks.
  • 输入
  • Input until EOF.
    There two positive integers m(2<m<50) and n(2<n<50) means the size of room.
    Then input the room.The room just includes T,X,O.T is the starting point of rat,X means the rat can not go,O means the blank.
    Next line follows a positive integer t(0<t<100) means the number of food.
    Then t lines follows.Each line includes two integers x(x>0) and y(y>0).x is the coordinate of line,y is the coordinate of column.
  • 输出
  • You should output the minimum step number the rat should do when he gets all of food.

  • 样例输入
  • 5 4
    2 1
    2 2
    3 2
    1 2
  • 样例输出
  • 5
  • 提示
  • 来源
  • hungar
  • 操作