#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int x,dp[10];
string s;
map<char,pair<int,int>> check;
int main() {
check['a']={2,1};check['b']={2,2};check['c']={2,3};
check['d']={3,1};check['e']={3,2};check['f']={3,3};
check['g']={4,1};check['h']={4,2};check['i']={4,3};
check['j']={5,1};check['k']={5,2};check['l']={5,3};
check['m']={6,1};check['n']={6,2};check['o']={6,3};
check['p']={7,1};check['q']={7,2};check['r']={7,3};check['s']={7,4};
check['t']={8,1};check['u']={8,2};check['v']={8,3};
check['w']={9,1};check['x']={9,2};check['y']={9,3};check['z']={9,4};
for (int i=1;i<=9;++i) cin >> x,dp[x]=i;
cin >> s;
auto the=check[s[0]];
for (int i=1;i<=the.s;++i) cout << dp[the.f];
for (int i=1;i<s.size();++i) {
auto the1=check[s[i]];
if (the.f==the1.f) cout << "#";
for (int i=1;i<=the1.s;++i) cout << dp[the1.f];
the=the1;
}
}
Compilation message
mobitel.cpp: In function 'int main()':
mobitel.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for (int i=1;i<s.size();++i) {
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |