Submission #931401

# Submission time Handle Problem Language Result Execution time Memory
931401 2024-02-21T18:01:25 Z AtinaR Mobitel (COCI14_mobitel) C++14
50 / 50
1 ms 436 KB
#include <bits/stdc++.h>

using namespace std;
map<char,string> mapa;
string f(int num)
{
    if(num==1)return "";
    if(num==2)return "abc";
    else if(num==3)return "def";
    else if(num==4)return "ghi";
    else if(num==5)return "jkl";
    else if(num==6)return "mno";
    else if(num==7)return "pqrs";
    else if(num==8)return "tuv";
    else if(num==9)return "wxyz";
}
int main()
{
    int niza[9];
    for(int i=0; i<9; i++)
    {
        cin>>niza[i];
    }
    string s;
    cin>>s;
    for(int i=0; i<9; i++)
    {
        int act_as=niza[i];
        string keys=f(act_as);
        int cnt=1;
        for(auto x:keys)
        {
            string tmp="";
            for(int k=0; k<cnt; k++)tmp+=(i+1)+'0';
            mapa[x]=tmp;
            cnt++;
        }
    }
    for(int i=0; i<s.size(); i++)
    {
        cout<<mapa[s[i]];
        if(i<s.size()-1)
        {
            if(mapa[s[i]][0]==mapa[s[i+1]][0])cout<<"#";
        }
    }
    cout<<endl;
    return 0;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0; i<s.size(); i++)
      |                  ~^~~~~~~~~
mobitel.cpp:42:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(i<s.size()-1)
      |            ~^~~~~~~~~~~
mobitel.cpp: In function 'std::string f(int)':
mobitel.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
   16 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 432 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 436 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct