-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4261.cpp
More file actions
58 lines (56 loc) · 1012 Bytes
/
4261.cpp
File metadata and controls
58 lines (56 loc) · 1012 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 4261. 빠른 휴대전화 키패드
// 2019.07.08
#include<iostream>
#include<vector>
#include<string>
using namespace std;
string keypad[10] = { "","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
vector<string> words;
int main()
{
int t;
cin >> t;
for (int testCase = 1; testCase <= t; testCase++)
{
words.clear();
string s;
cin >> s;
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
string word;
cin >> word;
words.push_back(word);
}
int ans = 0;
// 주어진 워드로 만들어 질 수 있는지 확인
for (int j = 0; j < n; j++)
{
string tmp = "";
string tmp2 = "";
for (int i = 0; i < s.size(); i++)
{
tmp = keypad[s[i] - '0'];
for (int k = 0; k < tmp.size(); k++)
{
if (tmp[k] == '1')
{
continue;
}
if (tmp[k] == words[j][i])
{
tmp2 += words[j][i];
break;
}
}
}
if (words[j] == tmp2)
{
ans++;
}
}
cout << "#" << testCase << " " << ans << endl;
}
return 0;
}