Submission #931401

#TimeUsernameProblemLanguageResultExecution timeMemory
931401AtinaRMobitel (COCI14_mobitel)C++14
50 / 50
1 ms436 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...