Submission #13839

# Submission time Handle Problem Language Result Execution time Memory
13839 2015-04-04T05:32:11 Z kipa00 Mobitel (COCI14_mobitel) C++
50 / 50
0 ms 1580 KB
#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 time Memory Grader output
1 Correct 0 ms 1580 KB Output is correct
2 Correct 0 ms 1580 KB Output is correct
3 Correct 0 ms 1580 KB Output is correct
4 Correct 0 ms 1580 KB Output is correct
5 Correct 0 ms 1580 KB Output is correct
6 Correct 0 ms 1580 KB Output is correct
7 Correct 0 ms 1580 KB Output is correct
8 Correct 0 ms 1580 KB Output is correct
9 Correct 0 ms 1580 KB Output is correct
10 Correct 0 ms 1580 KB Output is correct