-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path417_Word_Index.cpp
More file actions
77 lines (64 loc) · 2.01 KB
/
417_Word_Index.cpp
File metadata and controls
77 lines (64 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <bits/stdc++.h>
#define ALL(x) x.begin(), x.end()
#define FAST std::cin.tie(0); ios::sync_with_stdio(false); std::cout.tie(0);
using namespace std;
#define min(a,b) (a < b) ? (a) : (b)
#define max(a,b) (a > b) ? (a) : (b)
#define vii vector<pair<int,int>>
#define ii pair<int, int>
#define ll long long
#define endl '\n'
#define TC int t; cin >> t; while (t--)
void solve() {
cout << "Hi";
}
int main(int argc, char const *argv[])
{
unordered_map<string, int> index;
int count = 0;
for (char a = 'a'; a <= 'z'; a++) {
index[string(1, a)] = ++count;
}
for (char a = 'a'; a <= 'y'; a++) {
for (char b = a+1; b <= 'z'; b++) {
string x = string(1, a) + string(1, b);
index[x] = ++count;
}
}
for (char a = 'a'; a <= 'x'; a++) {
for (char b = a+1; b <= 'y'; b++) {
for (char c = b+1; c <= 'z'; c++) {
string x = string(1, a) + string(1, b) + string(1, c);
index[x] = ++count;
}
}
}
for (char a = 'a'; a <= 'w'; a++) {
for (char b = a+1; b <= 'x'; b++) {
for (char c = b+1; c <= 'y'; c++) {
for (char d = c+1; d <= 'z'; d++) {
string x = string(1, a) + string(1, b) + string(1, c) + string(1, d);
index[x] = ++count;
}
}
}
}
for (char a = 'a'; a <= 'v'; a++) {
for (char b = a+1; b <= 'w'; b++) {
for (char c = b+1; c <= 'x'; c++) {
for (char d = c+1; d <= 'y'; d++) {
for (char e = d+1; e <= 'z'; e++) {
string x = string(1, a) + string(1, b) + string (1, c) + string(1, d) + string (1, e);
index[x] = ++count;
}
}
}
}
}
string input;
while (cin >> input) {
if (index.find(input) != index.end()) cout << index[input] << endl;
else cout << 0 << endl;
}
return 0;
}