Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. s = [list(map(int, input().split())) for i in range(8)]
  2. for p in range(256):
  3.     ans = True
  4.     a = s[:][:]
  5.     u = [0 for i in range(33)]
  6.     for i in range(8):
  7.         x = -1
  8.         if (2 ** i) & p > 0:
  9.             x = 1
  10.         for j in range(8):
  11.             if a[i][j] * x < 0:
  12.                 if u[abs(a[i][j])] == 0 and i < 7 and a[i+1][j] == -a[i][j]:
  13.                     t = a[i+1][j]
  14.                     a[i+1][j] = a[i][j]
  15.                     a[i][j] = t
  16.                 else:
  17.                     ans = False
  18.             u[abs(a[i][j])] = 1
  19.     if ans:
  20.         print('YES')
  21.         raise SystemExit(0)
  22. print('NO')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement