• [F] First Choice

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • So clever the Wodex and his partners were! They got the right sort of values. But not over yet.

    What happened? The castle was shaking! Suddenly, the castle collapsed and they were swallowed up by dark.
    When they waked up, they found they were surrounded by lots of tall walls.

    At the same time, horn sounded:
    If you want to beat me, you should pass this level. Look at the map, there is a M * N maze, later you will be appeared in the map, each 1 * 1 lattice in the map means a room. There are only two characters 'X' and 'O' in the map, 'X' means that room is bad and you can not get in; 'O' means intact room that you can get in. There will must be a door and only one door between two adjoining and intact rooms. At the beginning, all of doors are opened, if you walk from one intact room to the adjoining and intact room, the door between them will close, that means you can not go again from these two rooms. Only all of doors are closed, you can be deliveried out of the maze and you will see me.
    Look, there is a transfer machine next to you, you can use it to choose any one room to get in the maze and you will start at that room.
    How can you walk to open all of doors? Start now!

  • 输入
  • There will be several test cases.
    First line will contain two integers M (0 < M < 100) and N (0 < N < 100).
    Then M lines, each line N characters, only contain 'O' and 'X'.
  • 输出
  • If they can open all of doors, print 'YES', otherwse print 'NO'.
    There will be at least one intact room.
  • 样例输入
  • 5 6
    OXXXOO
    OXXXXO
    OOOOOO
    XXXXXX
    XXXXXX
    3 3
    OOO
    OOO
    OOO
    3 3
    OOO
    XXX
    OOO
  • 样例输出
  • YES
    NO
    NO
  • 提示
  • 来源
  • Hungar
  • 操作

显示春菜