-
Notifications
You must be signed in to change notification settings - Fork 0
/
P9996.cpp
55 lines (45 loc) · 1.1 KB
/
P9996.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
#include <iostream>
#include <string>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
cin >> N;
string pattern;
cin >> pattern;
string front, back;
int check = 0;
for (int i = 0; i < pattern.length(); i++) {
if (!check) {
if (pattern[i] == '*') {
check = 1;
} else {
front.push_back(pattern[i]);
}
} else {
back.push_back(pattern[i]);
}
}
for (int i = 0; i < N; i++) {
int flag = 0;
string name;
cin >> name;
for (int j = 0; j < front.length(); j++) {
if (name[j] != front[j]) {
flag = 1;
break;
}
}
for (int j = back.length() - 1, k = name.length() - 1; j >= 0; j--, k--) {
if (name[k] != back[j] || (front.length() - 1) >= k) {
flag = 1;
break;
}
}
if (flag) cout << "NE\n";
else cout << "DA\n";
}
return 0;
}