Submission #163213

# Submission time Handle Problem Language Result Execution time Memory
163213 2019-11-11T20:05:28 Z beso123 Mobitel (COCI14_mobitel) C++14
50 / 50
2 ms 376 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 252 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 252 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct