Submission #468562

# Submission time Handle Problem Language Result Execution time Memory
468562 2021-08-28T18:13:01 Z ala2 Mobitel (COCI14_mobitel) C++14
50 / 50
1 ms 296 KB
#include <bits/stdc++.h>

using namespace std;
int a[1000100];
map<char,int>m;
map<int,string>m2;
int main()
{
    for(int i=1;i<=9;i++)
    {
        int x;
        cin>>x;
        a[x]=i;
    }
    m['a']=m['b']=m['c']=2;
    m['d']=m['e']=m['f']=3;
    m['g']=m['h']=m['i']=4;
    m['j']=m['k']=m['l']=5;
    m['m']=m['n']=m['o']=6;
    m['p']=m['q']=m['r']=m['s']=7;
    m['t']=m['u']=m['v']=8;
    m['w']=m['x']=m['y']=m['z']=9;
    m2[2]="abc";
    m2[3]="def";
    m2[4]="ghi";
    m2[5]="jkl";
    m2[6]="mno";
    m2[7]="pqrs";
    m2[8]="tuv";
    m2[9]="wxyz";
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(i>0&&m[s[i]]==m[s[i-1]])
            cout<<'#';
         int x=m[s[i]];
         string c=m2[x];
         for(int j=0 ; ;j++ )
         {
             cout<<a[x];
             if(c[j]==s[i])
                break;
         }
    }
    cout<<endl;

}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct