• [1257] Get Lost

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Leader Wang gets lost when he is walking in NB school.Now,there are many brands in the road.There will include the direction in brand(East, South, West and North).NB school is the size of M * N,and leader will follow the direction in brand,like map1 and map2.Can leader walk out of the map?
  • 输入
  • Input until EOF.
    First line contains two integets M(5<=M<=20) and N(5<=N<=20) indicates the size of school.
    Next line contains two integets x(0<=x<M) and y(0<=y<N) indicates the starting position of leader.
    Then M(from 0 to M-1) lines follows,each line contains N(from 0 to N-1) characters,every character(only is 'N' or 'S' or 'W' or 'E') indicates the direction in brand.
  • 输出
  • If leader can walk out of the map,output "YES",else output "NO".
  • 样例输入
  • 3 6
    0 4
    NEESWE
    WWWESS
    SNWWWW
    4 5
    0 0
    SESWE
    EESNW
    NWEEN
    EWSEN
  • 样例输出
  • YES
    NO
  • 提示
  • 来源
  • hungar
  • 操作

显示春菜