only. Do not copy. Correct code will upvoted else downvote.   Monocarp is playing a PC game. Presently he needs to finish the principal level of this game.    A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

C++ only. Do not copy. Correct code will upvoted else downvote.

 

Monocarp is playing a PC game. Presently he needs to finish the principal level of this game. 

 

A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the convergence of the 1-st line and the 1-st segment. 

 

Monocarp's character can move starting with one cell then onto the next in one stage if the cells are nearby by side or potentially corner. Officially, it is feasible to move from cell (x1,y1) to cell (x2,y2) in one stage if |x1−x2|≤1 and |y1−y2|≤1. Clearly, it is denied to go external the matrix. 

 

There are traps in certain cells. In case Monocarp's character winds up in such a cell, he bites the dust, and the game closures. 

 

To finish a level, Monocarp's character should arrive at cell (2,n) — at the crossing point of line 2 and section n. 

 

Assist Monocarp with deciding whether it is feasible to finish the level. 

 

Input 

 

The principal line contains a solitary integer t (1≤t≤100) — the number of experiments. Then, at that point, the experiments follow. Each experiment comprises of three lines. 

 

The principal line contains a solitary integer n (3≤n≤100) — the number of sections. 

 

The following two lines portray the level. The I-th of these lines portrays the I-th line of the level — the line comprises of the characters '0' and '1'. The character '0' compares to a protected cell, the character '1' relates to a snare cell. 

 

Extra limitation on the input: cells (1,1) and (2,n) are protected. 

 

Output 

 

For each experiment, output YES in case it is feasible to finish the level, and NO in any case.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education