#include<bits/stdc++.h>
using namespace std;
int main() {
map<int, string>q;
map<char, string>a;
q[1] = " ";
q[2] = "abc";
a[3] = "def";
q[4] = "ghi";
q[5] = "jkl";
q[6] = "mno";
q[7] = "pqrs";
q[8] = "tuv";
q[9] = "wxyz";
for (int i = 1; i <= 9; i++) {
int x; cin >> x;
if(x==1)continue;
string val = to_string(i);
string pp=q[x];
if(x==3){
pp="def";
}
for (auto c : pp) {
a[c] = val;
val += to_string(i);
}
val="";
}
string quest;
cin >> quest;
string res = "";
for (int i = 0; i < (int)quest.size(); i++) {
string ans = a[quest[i]];
if (i) {
if (ans[0] == res.back()) {
res += "#";
}
}
res += ans;
}
cout << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
432 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |