Submission #31177

# Submission time Handle Problem Language Result Execution time Memory
31177 2017-08-12T15:13:42 Z foul3r Mobitel (COCI14_mobitel) C++14
50 / 50
0 ms 2020 KB
#include <bits/stdc++.h>
 
int inp[15], print[15];
int key[] = {0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4};
int num[] = {0, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9};
char dap[1010];
int dpt;
 
int main()
{
    int i, j, l, id, r;
    char s[110];
    for(i=1;i<=9;i++){
        scanf("%d", &inp[i]);
        print[inp[i]]=i;
    }
    scanf("%s", s+1);
    l = strlen(s+1);
    for(i=1;i<=l;i++)
    {
        s[i] = s[i]-'a'+1;
        if(num[s[i]]%10 == num[s[i-1]]%10) dap[++dpt]='#';
        for(j=1;j<=key[s[i]];j++)
        {
            dap[++dpt]=num[s[i]]+48;
        }
    }
    for(i=1;i<=dpt;i++)
    {
        if(dap[i]>='0' && dap[i]<='9') printf("%d", print[dap[i]-48]);
        else printf("%c", dap[i]);
    }
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:22:20: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(num[s[i]]%10 == num[s[i-1]]%10) dap[++dpt]='#';
                    ^
mobitel.cpp:22:38: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(num[s[i]]%10 == num[s[i-1]]%10) dap[++dpt]='#';
                                      ^
mobitel.cpp:23:28: warning: array subscript has type 'char' [-Wchar-subscripts]
         for(j=1;j<=key[s[i]];j++)
                            ^
mobitel.cpp:25:32: warning: array subscript has type 'char' [-Wchar-subscripts]
             dap[++dpt]=num[s[i]]+48;
                                ^
mobitel.cpp:11:18: warning: unused variable 'id' [-Wunused-variable]
     int i, j, l, id, r;
                  ^
mobitel.cpp:11:22: warning: unused variable 'r' [-Wunused-variable]
     int i, j, l, id, r;
                      ^
mobitel.cpp:14:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &inp[i]);
                             ^
mobitel.cpp:17:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s+1);
                     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 0 ms 2020 KB Output is correct
5 Correct 0 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 0 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct