forked from Ouditchya/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARDA1.cpp
81 lines (63 loc) · 1.47 KB
/
ARDA1.cpp
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
// AC, ALGO : Brute Force.
/* Some Helpful Links :
http://www.cplusplus.com/reference/vector/vector/
http://www.cplusplus.com/reference/utility/pair/
http://www.cplusplus.com/reference/algorithm/sort/
*/
// For any clarifications, contact me at : [email protected]
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std ;
vector< pair< int , int > > v ;
int main( )
{
int i , j , x , y , X , Y , n1 , n2 , m1 , m2 , check ;
scanf("%d %d",&n1,&n2) ;
char home[n1][n2+1] ;
for( i = 0 ; i < n1 ; i++ )
scanf("%s",home[i]) ;
scanf("%d %d",&m1,&m2) ;
char map[m1][m2+1] ;
for( i = 0 ; i < m1 ; i++ )
scanf("%s",map[i]) ;
/* for( i = 0 ; i < n1 ; i++ )
printf("%s\n",home[i]) ;
printf("\n\n") ;
for( i = 0 ; i < m1 ; i++ )
printf("%s\n",map[i]) ; */
for( i = 0 ; i <= m1 - n1 ; i++ )
{
for( j = 0 ; j <= m2 - n2 ; j++ )
{
if( map[i][j] == home[0][0] )
{
for( check = 1 , x = 0 , X = i ; x < n1 ; x++ , X++ )
{
for( y = 0 , Y = j ; y < n2 ; y++ , Y++ )
{
if( map[X][Y] != home[x][y] )
{
check = 0 ;
break ;
}
}
}
if( check )
v.push_back( make_pair( i + 1 , j + 1 ) ) ;
}
}
}
if( v.empty( ) )
printf("NO MATCH FOUND...\n") ;
else
{
sort( v.begin( ) , v.end( ) ) ;
check = v.end( ) - v.begin( ) ;
for( i = 0 ; i < check ; i++ )
printf("(%d,%d)\n",v[i].first,v[i].second) ;
}
return 0 ;
}