This commit is contained in:
Zengtudor 2024-10-07 17:20:39 +08:00
parent f740b7ae66
commit d19837b878

View File

@ -0,0 +1,31 @@
#include <iostream>
#include <string>
#include <bitset>
#include <ranges>
static const size_t MAX_LEN {(size_t)2e3+5};
static std::string s,p;
static constexpr auto range {std::ranges::views::iota};
static std::bitset<MAX_LEN> dp[MAX_LEN];
int main(){
std::cin>>s>>p;
dp[0][0] = true;
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)=='*'){
dp[i][j] = dp[i-1][j] || dp[i][j-1]; //01背包查看是否使用这个字符
}
}
}
std::cout<<(dp[s.size()][p.size()]==true?"yes":"no")<<'\n';
}