This commit is contained in:
Zengtudor 2024-10-07 22:48:17 +08:00
parent b428e1c679
commit c533973e8b

View File

@ -10,12 +10,14 @@ static constexpr auto range {std::ranges::views::iota};
static std::bitset<MAX_LEN> dp[MAX_LEN];
int main(){
const auto get_p = [](const size_t n)noexcept->const char&{return p[n-1];};
const auto get_s = [](const size_t n)noexcept->const char&{return s[n-1];};
std::cin>>s>>p;
dp[0][0] = true;
for(const size_t j:range((size_t)1,p.size())){
const auto get_p = [](const size_t n)->char{return p[n-1];};
for(const size_t j:range((size_t)1,p.size()+1)){
if(get_p(j)=='*'){
dp[0][j] = dp[0][j-1];
}
@ -23,9 +25,6 @@ int main(){
for(const size_t i:range((size_t)1,s.size()+1)){
for(const size_t j:range((size_t)1,p.size()+1)){
const auto get_p = [](const size_t n)->char{return p[n-1];};
const auto get_s = [](const size_t n)->char{return s[n-1];};
if(get_p(j) == get_s(j) || get_p(j)=='?'){
dp[i][j] = dp[i-1][j-1];
}else if(get_p(j)=='*'){
@ -33,6 +32,5 @@ int main(){
}
}
}
std::cout<<(dp[s.size()][p.size()]==true?"yes":"no")<<'\n';
}