HDU3531暴力搜索

Description

There is a matrix of size n*n whose elements are either 0 or 1. Now your task is to find out that given a matrix of size m*m whose elements are also 0 or 1 whether it is a sub-matrix of the previous matrix.

Input

There is a matrix of size n*n whose elements are either 0 or 1. Now your task is to find out that given a matrix of size m*m whose elements are also 0 or 1 whether it is a sub-matrix of the previous matrix.

Output

If the second matrix is a sub-matrix of the first one, print “Yes” on a single line. Otherwise print “No”.

Sample Input

4 2
0 0 0 1
0 1 0 1
1 0 1 0
0 0 0 0
1 0
0 0
3 2
0 0 1
0 1 0
1 0 0
0 0
1 1

Sample Output

Yes

No

题意:这儿是一个n*n的矩阵元素值由0或1组成,给你两个矩阵让你找出一个矩阵是否为另一个的子矩阵。

思路:挨个遍历搜索应该可以,希望不会超时

你可能感兴趣的:(-----ACM水题-----,ACM算法入门)