-
Notifications
You must be signed in to change notification settings - Fork 0
/
Treasure
86 lines (82 loc) · 2.21 KB
/
Treasure
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
#include <iostream>
#include <string>
using namespace std;
void rotate_array(char **a, int size) {
char **new_array = new char* [size];
for (int i=0;i<size;i++){
new_array[i] = new char[size];
}
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
new_array[i][j] = a[i][j];
}
}
for (int i = 0; i < size; i++) {
for (int j = 0; j < size; j++) {
a[j][size - 1 - i] = new_array[i][j];
}
}
for(int i=0;i<size;i++){
delete[]new_array[i];
}
delete[]new_array;
}
int main() {
int size_treasure, size_map;
string input;
getline(cin, input);
size_treasure=stoi(input);
char **p = new char *[size_treasure];
for (int i = 0; i < size_treasure; i++) {
p[i] = new char[size_treasure];
}
for (int i = 0; i < size_treasure; i++) {
getline(cin, input);
for (int j = 0; j < size_treasure; j++) {
p[i][j] = input[j];
}
}
getline(cin, input);
size_map=stoi(input);
char **map = new char *[size_map];
for (int i = 0; i < size_map; i++) {
map[i] = new char[size_map];
}
for (int i = 0; i < size_map; i++) {
getline(cin, input);
for (int j = 0; j < size_map; j++) {
map[i][j] = input[j];
}
}
for (int i = 0; i <= (size_map - size_treasure); i++) {
for (int j = 0; j <= (size_map - size_treasure); j++) {
int n=0;
bool check=true;
while(n<4&&check){
for(int a=0;a<size_treasure;a++){
for(int b=0;b<size_treasure;b++){
check=check&&map[i+a][j+b]==p[a][b];
}
}
if(! check){
rotate_array(p, size_treasure);
n++;
check=true;
}
else{
cout << j << " " << i <<endl;
check=false;
}
}
}
}
for (int i = 0; i < size_map; i++) {
delete[]map[i];
}
for (int i = 0; i < size_treasure; i++) {
delete[]p[i];
}
delete[]map;
delete[]p;
return 0;
}