Advertisement
Guest User

Lab

a guest
Oct 30th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. lab = raw_input()
  2. N = len (lab)
  3. i = 1
  4. lab = list (lab)
  5. while i < N :
  6.     mas = raw_input()
  7.     mas = list (mas)
  8.     lab += mas
  9.     i += 1
  10. mas = (0,) * N * N
  11. stack = []
  12. i = 0
  13. stack.append(i)
  14. mas = list(mas)
  15. while stack != [] :
  16.     i = stack[0]
  17.     stack.pop(0)
  18.     mas[i] = 1
  19.     if i + 1 == N * N - 1 :
  20.         mas[i+1] = 1
  21.         break
  22.     else :
  23.         if i + 1 < N * N - 1 and lab[i+1] == '.' and mas[i+1] == 0 :
  24.             stack.append(i + 1)
  25.     if i + N == N * N - 1 :
  26.         mas[i+N] = 1
  27.         break
  28.     else :
  29.         if i + N < N * N - 1 and lab[i+N] == '.' and mas[i+N] == 0 :
  30.             stack.append(i + N)
  31. if mas[N * N - 1] == 0 :
  32.     print'NO'
  33. else :
  34.     print'YES'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement