0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P1246 编码

R52599287
This commit is contained in:
Baoshuo Ren 2021-07-08 10:40:54 +08:00 committed by Baoshuo Ren
parent bf8eb9215f
commit 915850f156
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,29 @@
#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
map<string, int> m;
string s1, s2;
void dfs(int l, int k) {
if (k > l) {
m[s1] = ++cnt;
return;
}
for (char c = (k == 1 ? 'a' : s1[k - 2] + 1); c <= 'z'; c++) {
s1[k - 1] = c;
dfs(l, k + 1);
}
}
int main() {
for (int i = 1; i <= 6; i++) {
s1.clear();
s1.resize(i);
dfs(i, 1);
}
cin >> s2;
cout << m[s2] << endl;
return 0;
}