답안 #163212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163212 2019-11-11T20:00:06 Z beso123 고장난 휴대전화기 (COCI14_mobitel) C++14
0 / 50
3 ms 424 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='-1';
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:24:8: warning: multi-character character constant [-Wmultichar]
 char l='-1';
        ^~~~
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:24:8: warning: overflow in implicit constant conversion [-Woverflow]
 char l='-1';
        ^~~~
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];
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 424 KB Output isn't correct
10 Halted 0 ms 0 KB -