Problem D: Daily Challenge

Xem dạng PDF

Gửi bài giải

Điểm: 1,00
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 500M
Input: stdin
Output: stdout

Tác giả:
Dạng bài

Trong trường hợp đề bài hiển thị không chính xác, bạn có thể tải đề bài tại đây: Đề bài

Luna is testing his pathfinding skills in a grid-based navigation challenge. The challenge features a grid with 2 rows and n columns, where Luna's starting position is at the top-left corner, cell (1,1).

In this challenge, Luna's piece can move to any adjacent cell in a single step, including diagonally. Formally, movement from cell ~(x1,y1)~ to cell ~(x2,y2)~ is allowed if ~|x1 - x2| ≤ 1~ and ~|y1 - y2| ≤ 1~. Moving outside the grid boundaries is not permitted.

Certain cells in the grid contain obstacles that cause failure if Luna's piece lands on them. The objective is to navigate from the starting cell to the bottom-right corner of the grid, cell (2,n), without encountering any obstacles.

Your goal is to determine if it is possible for Luna to reach the destination cell given the placement of obstacles.


Input

The first line contains a single integer ~n~ ~(3 ≤ n ≤ 100)~ - the number of columns in the grid.

The next two lines describe the grid. Each of these lines represents one row of the grid - each line consists of characters '0' and '1'. The character '0' indicates a safe cell, while the character '1' indicates a trap cell.

An additional constraint is that cells (1,1) and (2,n) are safe.


Output

Output ~YES~ if it is possible to complete the challenge, and ~NO~ otherwise.


Sample Input 1

6
010101
101010

Sample Ouput 1

YES


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.