0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 04:58:49 +00:00
OI-codes/Luogu/problem/P1246/P1246.cpp

30 lines
479 B
C++
Raw Normal View History

2021-07-08 02:40:54 +00:00
#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;
}