DP-Algo
This commit is contained in:
24
std-Cpp/regex/UVA10340 子序列 All in All.cpp
Normal file
24
std-Cpp/regex/UVA10340 子序列 All in All.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
int main() {
|
||||
std::string s, t;
|
||||
while (std::cin >> s >> t) {
|
||||
std::string pattern;
|
||||
for (char c : s) {
|
||||
pattern += std::regex_escape(std::string(1, c)) + ".*";
|
||||
}
|
||||
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .*
|
||||
if (!pattern.empty()) pattern = pattern.substr(0, pattern.size() - 2);
|
||||
|
||||
std::regex re(pattern);
|
||||
if (std::regex_match(t, re)) {
|
||||
std::cout << "Yes\n";
|
||||
} else {
|
||||
std::cout << "No\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user