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:
parent
bf8eb9215f
commit
915850f156
29
Luogu/problem/P1246/P1246.cpp
Normal file
29
Luogu/problem/P1246/P1246.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user