Submission #702328

#TimeUsernameProblemLanguageResultExecution timeMemory
702328delreyMobitel (COCI14_mobitel)C++14
50 / 50
1 ms296 KiB
#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 timeMemoryGrader output
Fetching results...