# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87700 | asifthegreat | Mobitel (COCI14_mobitel) | C++14 | 3 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int mp[100];
map<char,int>number;
void doit()
{
number['a'] = 2;
number['b'] = 2;
number['c'] = 2;
number['d'] = 3;
number['e'] = 3;
number['f'] = 3;
number['g'] = 4;
number['h'] = 4;
number['i'] = 4;
number['j'] = 5;
number['k'] = 5;
number['l'] = 5;
number['m'] = 6;
number['n'] = 6;
number['o'] = 6;
number['p'] = 7;
number['q'] = 7;
number['r'] = 7;
number['s'] = 7;
number['t'] = 8;
number['u'] = 8;
number['v'] = 8;
number['w'] = 9;
number['x'] = 9;
number['y'] = 9;
number['z'] = 9;
}
int main()
{
doit();
int ss;
for(int i = 1; i <= 9;i++){
scanf("%d",&ss);
mp[ss] = i;
}
string s,ans;
cin >> s;
int size = s.size();
for(int i = 0; i < size;i++){
int k = number[s[i]];
int cnt = 0;
for(char x = s[i];x >= 'a';x--){
if(number[x] == k)cnt++;
}
//cout << k << " " << cnt << endl;
if(ans.empty() or ans.back() != k+'0'){
//cout << "papa " << endl;
for(int p = 1; p <= cnt;p++)ans.push_back((char)(k+'0'));
}
else{
ans.push_back('#');
for(int p = 1; p <= cnt;p++)ans.push_back((char)(k+'0'));
}
}
//cout << ans << endl;
for(auto i: ans){
if(i == '#')cout << i;
else{
int k = i-'0';
cout << mp[k];
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |