判断第二个矩阵是不是第一个矩阵的子矩阵,怎么用C语言的程序的代码的编写的思想的方式去实现的程序

Problem 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

#include<stdio.h>
int main()
{
int a[10][10],b[10][10],N,M,x=-1,y,flag,i,j;
scanf("%d",&N);
for(int i=0; i<N; i++)
{
for(int j=0; j<N; j++)
{
scanf("%d",&a[i][j]);
}
}
scanf("%d",&M);
for(int i=0; i<M; i++)
{
for(int j=0; j<M; j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0; i<=N-M; i++)
{
for(j=0; j<=N-M; j++)
{
if(a[i][j]==b[0][0])
{
flag=1;
for(int k=0; k<M; k++)
{
for(int u=0; u<M; u++)
{
if(a[i+k][j+u]!=b[k][u])
flag=-1;
}
}
if(flag==1)
{
y=i;
x=j;
}
break;
}
}
}
if(x!=-1) printf("%d,%d",y+1,x+1);

else printf("-1");
return 0;

}