-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSub Matrix Search
More file actions
90 lines (77 loc) · 1.3 KB
/
Sub Matrix Search
File metadata and controls
90 lines (77 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
int n,m,a[21][21],b[20][20],d[21][21]={0};
int i,j,i1=1,j1=1,count=0,flag=0;;
cin>>n>>m;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
cin>>b[i][j];
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
count=0;
if(i==0 || j==0)
d[i][j]=1;
else
{
if(a[i-1][j]==b[i1-1][j1] &&
a[i-1][j-1]==b[i1-1][j1-1] &&
a[i][j-1]==b[i1][j1-1] && a[i][j]==b[i1][j1])
{
d[i][j]=min(min(d[i-1][j],d[i-1][j-1]),d[i][j-1])+1;
cout<<"hgk";
}
else
d[i][j]=1;
}
if(d[i][j]>1)
count=1;
if(j1==m-1 && count==1)
{
i1++;
printf("hyli");
j1=1;
}
else if(count==1)
{
j1++;
printf("jk");
}
if(d[i][j]==m)
{
flag=1;
break;
}
}
if(flag==1)
{
break;
}
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
cout<<d[i][j]<<" ";
}
cout<<"\n";
}
if(flag==1)
cout<<"TRUE";
else
cout<<"FALSE";
}