-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_1567.cpp
More file actions
38 lines (33 loc) · 757 Bytes
/
task_1567.cpp
File metadata and controls
38 lines (33 loc) · 757 Bytes
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
#include <iostream>
#include <string>
#include <vector>
#include <map>
const std::vector<std::string> KEYBOARD = {
"1", "abc",
"2", "def",
"3", "ghi",
"4", "jkl",
"5", "mno",
"6", "pqr",
"7", "stu",
"8", "vwx",
"9", "yz",
"0", ".,!",
"#", " ",
};
int main() {
std::map<char, int> char2taps;
for(const auto & keyboard_chars: KEYBOARD) {
for(int i = 0; i < keyboard_chars.size(); i++) {
char2taps[keyboard_chars[i]] = i + 1;
}
}
std::string slogan;
std::getline(std::cin, slogan);
int num_taps = 0;
for(const auto& c: slogan) {
num_taps += char2taps[c];
}
std::cout << num_taps;
return 0;
}