Известно, что на доске 8×8 можно расставить 8 ферзей так, чтобы они не били друг друга. Вам дана рас
Python
def are_queens_attacking(queens):
for i in range(7):
for j in range(i + 1, 8):
if queens[i][0] == queens[j][0] or \
queens[i][1] == queens[j][1] or \
abs(queens[i][0] - queens[j][0]) == abs(queens[i][1] - queens[j][1]):
return True
return False
# Считываем координаты ферзей
queens = [tuple(map(int, input().split())) for _ in range(8)]
# Проверяем, бьют ли ферзи друг друга
if are_queens_attacking(queens):
print("YES")
else:
print("NO")
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.