-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·46 lines (36 loc) · 1.11 KB
/
Copy pathsol.cpp
File metadata and controls
executable file
·46 lines (36 loc) · 1.11 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
#include <bits/stdc++.h>
using namespace std;
int main()
{
// clang-format off
unordered_map<char, pair<int, int>> M = {
{'a', {2, 1}}, {'b', {2, 2}}, {'c', {2, 3}},
{'d', {3, 1}}, {'e', {3, 2}}, {'f', {3, 3}},
{'g', {4, 1}}, {'h', {4, 2}}, {'i', {4, 3}},
{'j', {5, 1}}, {'k', {5, 2}}, {'l', {5, 3}},
{'m', {6, 1}}, {'n', {6, 2}}, {'o', {6, 3}},
{'p', {7, 1}}, {'q', {7, 2}}, {'r', {7, 3}}, {'s', {7, 4}},
{'t', {8, 1}}, {'u', {8, 2}}, {'v', {8, 3}},
{'w', {9, 1}}, {'x', {9, 2}}, {'y', {9, 3}}, {'z', {9, 4}},
{' ', {0, 1}}
};
//clang-format on
int n;
cin >> n;
cin.ignore();
for (int i = 1; i <= n; ++i) {
string line;
getline(cin, line);
string result = "";
int prev = -1;
for (char c : line) {
int t9char = M[c].first;
int times = M[c].second;
if (prev == t9char) result += ' ';
while (times--) result += to_string(t9char);
prev = t9char;
}
printf("Case #%d: %s\n", i, result.c_str());
}
return 0;
}