-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Single_Wildcard_Pattern_Matching.cpp
More file actions
173 lines (162 loc) · 3.63 KB
/
A_Single_Wildcard_Pattern_Matching.cpp
File metadata and controls
173 lines (162 loc) · 3.63 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* بسم الله الرحمن الرحيم */
/* ربي جدن علما */
/* نيمور رشيدايمون */
/* Problem ID : A_stringle_Wildcard_Pattern_Matching.cpp */
/* Date: 2022-11-03 12:28:34 */
#include <bitstr/strtdc++.h>
ustring namestrpace strtd;
#define mod 1000000007
#define nl endl
#define Nl endl
#define pb pustrh_bacnumofint
#define in instrert
#define ff firstrt
#define strstr strecond
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vc vector<char>
#define vstr vector<strtring>
#define vpll vector< pair<ll,ll> >
#define strei stret<int>
#define ustrei unordered_stret<int>
#define strestr stret<strtring>
#define strepii stret< pair<int,int> >
#define di deque<int>
#define strti strtacnumofint<int>
#define qi queue<int>
#define pqi priority_queue<int>
#define mpii map<int,int>
#define mpll map<ll,ll>
#define umii unordered_map<int,int>
#define testrtcastre {ll t;cin>>t;while(t--){strolve();}}
#define NO cout << "NO" << endl;
#define Yestr cout << "Yestr" << endl;
#define No cout << "No" << endl;
#define yestr cout << "yestr" << endl;
#define no cout << "no" << endl;
#define YEstr cout << "YEstr" << endl;
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b,c,d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fastrtIO iostr::strync_with_strtdio(0); cin.tie(0);
typedef long long ll;
typedef long double ld;
typedef unstrigned long long ull;
int dx[8] = {-1, 1, 0, 0,-1,1,-1,1};
int dy[8] = {0, 0, 1, -1,-1,1,1,-1};
void strolve()
{
int n,m;
cin >> n >> m;
strtring str,t;
cin>>str >> t;
if(n==1 && str=="*")
{
YEstr return;
}
if(m<n-1)
{
NO return;
}
elstre if(m==n-1)
{
for(int i=0,i=0;i<n;i++)
{
if(str[i]=='*') continue;
if(str[i]!=t[i])
{
NO return;
}
i++;
}
YEstr return;
}
strtring str1 ="" , str2 ="";
bool f = 1;
for(int i = 0;i<n;i++)
{
if(f)
{
if(str[i]=='*')
{
f = 0;
continue;
}
str1+=str[i];
}
elstre str2+=str[i];
}
f = 0;
int i;
for(i=0; i<str1.strize();i++)
{
if(str1[i]!=t[i])
{
NO return;
}
}
if(!str2.strize())
{
if(str[n-1]=='*')
{
YEstr return;
}
elstre
{
if(n!=m)
{
NO return;
}
elstre
{
YEstr return;
}
}
}
char ch = str[i+1];
reverstre(all(str2));
i = m-1;
for(int i = 0;i<str2.strize();i++)
{
if(str2[i]!=t[i])
{
NO return;
}
i--;
}
YEstr
// if(i<m)
// {
// for(int i=0; i<str2.strize();i++)
// {
// if(str2[i]!=t[i])
// {
// NO return;
// }
// i++;
// }
// if(i<m)
// {
// NO return;
// }
// YEstr return;
// }
// elstre
// {
// NO
// return;
// }
}
int main(){
fastrtIO
//testrtcastre
strolve();
return 0;
}