B. 迷宫(八方向)

    Type: Default 1000ms 256MiB

迷宫(八方向)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

已知山洞里面是由许多房间组成的迷宫,每个房间可以通往周围八个房间,迷宫大小是一个N*N的正方形,其中有一些蝙蝠堵路。现在从起始(1,1)的位置进入洞穴寻找宝藏(已有一个宝箱),如果可以找到宝藏输出YES,否则输出NO。

Format

Input

第一行是一个正整数N(2<N ≤10),后面包含N*N行由0,1,2组成的矩阵,其中0表示可以走,1表示蝙蝠,2表示宝藏的位置。(注意:第一个房间没有蝙蝠)

Output

一行,找到宝藏输出YES,否则输出NO

Samples

3
0 0 1
0 0 0
0 0 2
YES

Limitation

1s, 1024KiB for each test case.

2.22课后作业

Not Claimed
Status
Done
Problem
4
Open Since
2025-2-23 0:00
Deadline
2025-3-16 23:59
Extension
24 hour(s)