Solve problem "Queens" online - Learn Python 3 - Snakify

Problem «Queens» (Hard)


Statement

In chess it is known that it is possible to place 8 queens on an 8×8 chess board such that none of them can attack another. Given a placement of 8 queens on the board, determine if there is a pair of queens that can attach each other on the next move. Print the word NO if no queen can attack another, otherwise print YES. The input consists of eight coordinate pairs, one pair per line, with each pair giving the position of a queen on a standard chess board with rows and columns numbered starting at 1.

In all the problems input the data using input() and print the result using print().



Saved solutions

Tests

Input Correct answer Result
1 7
2 4
3 2
4 8
5 6
6 1
7 3
8 5
NO
1 8
2 7
3 6
4 5
5 4
6 3
7 2
8 1
YES
3 4
8 5
4 1
7 3
6 6
1 7
5 8
2 2
YES
2 5
8 4
3 7
4 1
6 8
7 6
1 2
5 3
NO
1 3
4 8
6 1
5 5
2 7
8 6
7 4
3 2
NO
7 8
2 2
8 5
4 3
5 7
1 4
6 1
3 6
YES
7 5
8 3
5 6
1 4
2 2
6 8
3 7
4 1
YES
4 6
5 1
3 7
8 3
2 2
1 4
7 5
6 8
YES
2 2
3 5
8 6
7 4
5 1
1 4
4 3
6 7
YES
3 4
7 6
6 8
4 7
4 1
2 2
1 5
5 3
YES
5 6
6 4
7 7
1 3
8 5
3 6
2 1
4 8
YES
6 5
3 1
8 4
5 8
1 2
7 7
6 3
4 6
YES
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
YES
1 7
2 1
3 2
4 3
5 4
6 6
7 8
8 5
YES