题解:AT_past202004_d パターンマッチ
题目简述
给你一个只包含小写字母的字符串 .,并且与 . 可以代表任意字符,求与
主要思路
由于 .,要么是其对应的 set 去重。
AC Code
#include<set>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int INT_INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T1, typename T2, typename T3> T1 _pow(T1 a, T2 b, T3 mod = LL_INF) { T1 x = 1, y = a; while(b > 0) {if (b & 1) x = x * y % mod; y = y * y % mod; b >>= 1; } return x; }
// ----------------------------
// ----------------------------
set<string> st;
// ----------------------------
void dfs(int u, int n, string s, string t) {
if (u >= n) {
st.insert(t);
return;
}
t += '.';
dfs(u + 1, n, s, t);
t.pop_back(); t += s[u];
dfs(u + 1, n, s, t);
}
int main() {
string s; cin >> s;
// ----------------------------
for (int i = 1; i <= 3; i++) {
for (int j = 0; j + i - 1 < (int)s.length(); j++) {
dfs(0, i, s.substr(j, i), "");
}
}
// ----------------------------
cout << st.size();
return 0;
}