codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

128A.md (2764B)


      1 Source: https://codeforces.com/problemset/problem/128/A
      2 
      3 A. Statues
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone — neither any other statues, nor Anna, nor Maria.
     22 
     23 Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is — to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.
     24 
     25 At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.
     26 
     27 Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.
     28 
     29 Input
     30 
     31 You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one — for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is ".". If a cell has Maria, then it is represented by character "M". If a cell has Anna, it is represented by the character "A". If a cell has a statue, then the cell is represented by character "S".
     32 
     33 It is guaranteed that the last character of the first row is always "A", the first character of the last line is always "M". The remaining characters are "." or "S".
     34 
     35 Output
     36 
     37 If Maria wins, print string "WIN". If the statues win, print string "LOSE".
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 .......A  
     45 ........  
     46 ........  
     47 ........  
     48 ........  
     49 ........  
     50 ........  
     51 M.......
     52 ```
     53 
     54 Output
     55 
     56 ```
     57 WIN
     58 ```
     59 
     60 Input
     61 
     62 ```
     63 .......A  
     64 ........  
     65 ........  
     66 ........  
     67 ........  
     68 ........  
     69 SS......  
     70 M.......
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 LOSE
     77 ```
     78 
     79 Input
     80 
     81 ```
     82 .......A  
     83 ........  
     84 ........  
     85 ........  
     86 ........  
     87 .S......  
     88 S.......  
     89 MS......
     90 ```
     91 
     92 Output
     93 
     94 ```
     95 LOSE
     96 ```