답안 #85890

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85890 2018-11-22T14:11:19 Z memetkagan44 고장난 휴대전화기 (COCI14_mobitel) C++11
50 / 50
3 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
int a,gst[15];
char ar[105];
map<char,pair<int,int> > val;
int main(){
    for(int i=1;i<=9;i++){
        scanf("%d",&a);
        gst[a]=i;
    }
    scanf("%s",ar+1);
    char c='a';
    for(int i=2; c<='r' ;i++)
        for(int j=1;j<=3;j++,c++)
            val[c]=make_pair(gst[i],j);
    val[c++]=make_pair(gst[7],4);
    for(int i=8; c<='y';i++)
        for(int j=1;j<=3;j++,c++)
            val[c]=make_pair(gst[i],j);
    val[c]=make_pair(gst[9],4);
    for(int i=1,k=-1;i<=strlen(ar+1);i++){
        if(k==val[ar[i]].first)
            printf("#");
        k=val[ar[i]].first;
        for(int j=1;j<=val[ar[i]].second;j++)
            printf("%d",k);
    }
    printf("\n");
    return 0;
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:21:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=1,k=-1;i<=strlen(ar+1);i++){
                      ~^~~~~~~~~~~~~~
mobitel.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
         ~~~~~^~~~~~~~~
mobitel.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s",ar+1);
     ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 2 ms 612 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 2 ms 612 KB Output is correct
6 Correct 2 ms 612 KB Output is correct
7 Correct 2 ms 612 KB Output is correct
8 Correct 2 ms 612 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 2 ms 640 KB Output is correct