Submission #702328

# Submission time Handle Problem Language Result Execution time Memory
702328 2023-02-23T14:43:04 Z delrey Mobitel (COCI14_mobitel) C++14
50 / 50
1 ms 296 KB
#include <iostream>

using namespace std;

int main()
{
    int code[26][2] =
    {
        {2, 1}, {2, 2}, {2, 3},
        {3, 1}, {3, 2}, {3, 3},
        {4, 1}, {4, 2}, {4, 3},
        {5, 1}, {5, 2}, {5, 3},
        {6, 1}, {6, 2}, {6, 3},
        {7, 1}, {7, 2}, {7, 3}, {7, 4},
        {8, 1}, {8, 2}, {8, 3},
        {9, 1}, {9, 2}, {9, 3}, {9, 4}
    };
    int key[10];
    for(int i = 1; i <= 9; i++)
    {
        int a;
        cin>>a;
        key[a] = i;
    }
    string text;
    cin>>text;
    int n = text.length();
    for(int i = 0; i < n - 1; i++)
    {
        int idx = text[i] - 'a', idx2 = text[i + 1] - 'a';
        for(int j = 0; j < code[idx][1]; j++)
            cout<<key[code[idx][0]];
        if(code[idx][0] == code[idx2][0])
            cout<<"#";
        //cout<<endl<<"idx: "<<idx<<" text[i]: "<<text[i]<<" idx2: "<<idx2<<" text[i + 1]: "<<text[i + 1]<<endl;
    }
    int idx = text[n - 1] - 'a';
    for(int j = 0; j < code[idx][1]; j++)
        cout<<key[code[idx][0]];
    //cout<<endl<<"idx: "<<idx<<" text["<<idx<<"]: "<<text[idx]<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct