Preparing NOJ

Rooks

1000ms 65536K

Description:

Jake and Sully are playing around with a chessboard one night after working with their avatars all

day. They decide it would be interesting to place some rooks on the chessboard in a way that no rook

can threaten another rook. Since rooks move along rows and columns, this means two rooks may not

be on the same row or column. Your goal is to write a program to determine whether any rooks are

threatened.


Input:

Chessboards are 8x8 boards with positions between (1,1) and (8,8). The input begins with the

number of chess boards. Each chessboard is on a separate line and begins with the number of rooks,

followed by the column and row positions of each rook.


Output:

For each chessboard, your program should output the words ”SAFE” or ”NOT SAFE” on a

single line.


Sample Input:

2
3 1 1 2 6 8 8
2 2 3 1 3

Sample Output:

SAFE
NOT SAFE

Note:

undefined

本题由旧版NOJ导入,来源:Internet

Info

NOJ

Provider NOJ

Code NOJ1390

Tags

Submitted 2

Passed 2

AC Rate 100%

Date 04/20/2019 10:03:10

Related

Nothing Yet