답안 #147400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147400 2019-08-29T12:56:47 Z mariadinca 고장난 휴대전화기 (COCI14_mobitel) C++14
50 / 50
2 ms 376 KB
#include <iostream>

using namespace std;

int n, c[200], i, j, x, comp[11];
char s[120], ant, car;
int sol[200];

int main(){
    c['a'] = c['b'] = c['c'] = 2;
    sol['a'] = 1, sol['b'] = 2, sol['c'] = 3;
    c['d'] = c['e'] = c['f'] = 3;
    sol['d'] = 1, sol['e'] = 2, sol['f'] = 3;
    c['g'] = c['h'] = c['i'] = 4;
    sol['g'] = 1, sol['h'] = 2, sol['i'] = 3;
    c['j'] = c['k'] = c['l'] = 5;
    sol['j'] = 1, sol['k'] = 2, sol['l'] = 3;
    c['m'] = c['n'] = c['o'] = 6;
    sol['m'] = 1, sol['n'] = 2, sol['o'] = 3;
    c['p'] = c['q'] = c['r'] = c['s'] = 7;
    sol['p'] = 1, sol['q'] = 2, sol['r'] = 3, sol['s'] = 4;
    c['t'] = c['u'] = c['v'] = 8;
    sol['t'] = 1, sol['u'] = 2, sol['v'] = 3;
    c['w'] = c['x'] = c['y'] = c['z'] = 9;
    sol['w'] = 1, sol['x'] = 2, sol['y'] = 3, sol['z'] = 4;
    for(i=1;i<=9;i++){
        cin>>x;
        comp[x] = i;
    }
    cin>>s;
    car = s[0];
    for(j=1;j<=sol[car];j++)
        cout<<comp[c[car]];
        ant = car;
    for(i=1;s[i]!=0;i++){
        car = s[i];
        if(c[car] == c[ant])
            cout<<"#";
        for(j=1;j<=sol[car];j++)
            cout<<comp[c[car]];
            ant = car;
    }
    return 0;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:32:23: warning: array subscript has type 'char' [-Wchar-subscripts]
     for(j=1;j<=sol[car];j++)
                       ^
mobitel.cpp:33:25: warning: array subscript has type 'char' [-Wchar-subscripts]
         cout<<comp[c[car]];
                         ^
mobitel.cpp:32:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(j=1;j<=sol[car];j++)
     ^~~
mobitel.cpp:34:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         ant = car;
         ^~~
mobitel.cpp:37:17: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(c[car] == c[ant])
                 ^
mobitel.cpp:37:27: warning: array subscript has type 'char' [-Wchar-subscripts]
         if(c[car] == c[ant])
                           ^
mobitel.cpp:39:27: warning: array subscript has type 'char' [-Wchar-subscripts]
         for(j=1;j<=sol[car];j++)
                           ^
mobitel.cpp:40:29: warning: array subscript has type 'char' [-Wchar-subscripts]
             cout<<comp[c[car]];
                             ^
mobitel.cpp:39:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(j=1;j<=sol[car];j++)
         ^~~
mobitel.cpp:41:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             ant = car;
             ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 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 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct