Submission #201449

#TimeUsernameProblemLanguageResultExecution timeMemory
201449EmmanuelACMobitel (COCI14_mobitel)C++14
50 / 50
5 ms376 KiB
#include<bits/stdc++.h> using namespace std; char v[9]; char last, curr; int key(char c){ if(c >= 'a' && c <= 'c'){ curr = v[1]; return 1 + (int)(c - 'a'); } if(c >= 'd' && c <= 'f'){ curr = v[2]; return 1 + (int)(c - 'd'); } if(c >= 'g' && c <= 'i'){ curr = v[3]; return 1 + (int)(c - 'g'); } if(c >= 'j' && c <= 'l'){ curr = v[4]; return 1 + (int)(c - 'j'); } if(c >= 'm' && c <= 'o'){ curr = v[5]; return 1 + (int)(c - 'm'); } if(c >= 'p' && c <= 's'){ curr = v[6]; return 1 + (int)(c - 'p'); } if(c >= 't' && c <= 'v'){ curr = v[7]; return 1 + (int)(c - 't'); } if(c >= 'w' && c <= 'z'){ curr = v[8]; return 1 + (int)(c - 'w'); } } int main(){ for(int i=0; i<9; i++){ int aux; cin >> aux; v[aux -1] = (char)('1' +i); } string s; cin >> s; last = '*'; for(auto c : s){ int k = key(c); if(curr == last) cout << "#"; for(int i=0; i<k; i++) cout << curr; last = curr; } cout << "\n"; }

Compilation message (stderr)

mobitel.cpp: In function 'int key(char)':
mobitel.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
 } 
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...