Submission #163213

#TimeUsernameProblemLanguageResultExecution timeMemory
163213beso123Mobitel (COCI14_mobitel)C++14
50 / 50
2 ms376 KiB
#include<bits/stdc++.h> #define int long long using namespace std; string s; int a[10]; map <int,string> mp; main(){ mp[2]="abc"; mp[3]="def"; mp[4]="ghi"; mp[5]="jkl"; mp[6]="mno"; mp[7]="pqrs"; mp[8]="tuv"; mp[9]="wxyz"; for(int k=1;k<=9;k++){ int h; cin>>h; a[h]=k; } cin>>s; string ans=""; char l='&'; for(int k=0;k<s.size();k++){ string pas=""; for(int i=2;i<=9;i++){ for(int j=0;j<mp[i].size();j++){ if(s[k]==mp[i][j]){ int u=a[i]; if(j>=0) pas+=(u+'0'); if(j>=1) pas+=(u+'0'); if(j>=2) pas+=(u+'0'); if(j>=3) pas+=(u+'0'); break; } } } if(l==pas[0]) ans=ans+'#'+pas; else ans=ans+pas; l=pas[0]; } cout<<ans; return 0; }

Compilation message (stderr)

mobitel.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
mobitel.cpp: In function 'int main()':
mobitel.cpp:25:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(int k=0;k<s.size();k++){
             ~^~~~~~~~~
mobitel.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<mp[i].size();j++){
                     ~^~~~~~~~~~~~~
mobitel.cpp:45:4: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
    else ans=ans+pas;
    ^~~~
mobitel.cpp:46:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
         l=pas[0];
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...