Submission #13839

#TimeUsernameProblemLanguageResultExecution timeMemory
13839kipa00Mobitel (COCI14_mobitel)C++98
50 / 50
0 ms1580 KiB
#include <cstdio> #include <string> using std::string; string res; string tonum[26] = {"2","22","222","3","33","333","4","44","444","5","55","555","6","66","666","7","77","777","7777","8","88","888","9","99","999","9999"}; void add(string str) { if (res.length() == 0) { res += str; } else if (res[res.length() - 1] == str[0]) { res += "#" + str; } else { res += str; } } int main() { int arr[9]; char str[105], *ptr = str; int n; for (n=0; n<9; ++n) { int temp; scanf("%d", &temp); arr[temp - 1] = n + 1; } scanf("%s", str); for (;*ptr;++ptr) { add(tonum[*ptr - 'a']); } for (n=0;n<res.length();++n) { if ('2' <= res[n] && res[n] <= '9') { printf("%d", arr[res[n] - '1']); } else printf("#"); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...