GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 7 October 2022

[Solution] Ela and Crickets Codeforces Solution



C. Ela and Crickets
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The problem, which involves a non-standard chess pieces type that is described below, reads: given 

3 white crickets on a nn board, arranged in an "L" shape next to each other, there are no other pieces on the board. Ela wants to know with a finite number of moves, can she put any white cricket on the square on row x, column y?

An "L"-shape piece arrangement can only be one of the below:

For simplicity, we describe the rules for crickets on the board where only three white crickets are. It can move horizontally, vertically, or diagonally, but only to a square in some direction that is immediately after another cricket piece (so that it must jump over it). If the square immediately behind the piece is unoccupied, the cricket will occupy the square. Otherwise (when the square is occupied by another cricket, or does not exist), the cricket isn't allowed to make such a move.

See an example of valid crickets' moves on the pictures in the Note section.

Input

Each test contains multiple test cases. The first line contains the number of test cases t (1t104). The description of the test cases follows.

The first line of each test case contains n (4n105) — denotes the size of the chessboard.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

The second line of each test case contains 6 numbers: r1c1r2c2r3c3 (1r1,c1,r2,c2,r3,c3n) — coordinates of the crickets. The input ensures that the three crickets are arranged in an "L" shape that the legend stated.

The third line of each test case contains 2 numbers: xy (1x,yn) — coordinates of the target square.

Output

For each test case, print "YES" or "NO" to denotes whether Ela can put a cricket on the target square.

No comments:

Post a Comment