# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
87700 | 2018-12-02T05:31:24 Z | asifthegreat | Mobitel (COCI14_mobitel) | C++14 | 3 ms | 604 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 400 KB | Output is correct |
4 | Correct | 2 ms | 400 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 532 KB | Output is correct |
7 | Correct | 3 ms | 532 KB | Output is correct |
8 | Correct | 1 ms | 572 KB | Output is correct |
9 | Correct | 3 ms | 604 KB | Output is correct |
10 | Correct | 2 ms | 604 KB | Output is correct |