답안 #10707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
10707 2014-11-09T13:17:35 Z tncks0121 고장난 휴대전화기 (COCI14_mobitel) C++14
50 / 50
0 ms 1096 KB
#include <cstdio>

using namespace std;

int num[26], perm[26], t[26];
char s[10000];

int main() {
  for(char c = 'a', n = 2; n <= 9; n++) {
    int a;
    t[n] = c - 'a';
    if(n == 7 || n == 9) a = 4; else a = 3;
    for(char i = c; i < c+a; i++) num[i - 'a'] = n;
    c += a;
  }
  
  
  for(int i = 1; i <= 9; i++) {
    int x; scanf("%d", &x);
    perm[x] = i;
  }
  
  scanf("%s", s);
  int pv = -1;
  for(char *p = s; *p; p++) {
    *p -= 'a';
    if(pv == num[*p]) putchar('#'); pv = num[*p];
    int ac = *p - t[num[*p]] + 1;
    while(ac--) putchar('0' + perm[num[*p]]);
  }
 return 0; 
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1096 KB Output is correct
2 Correct 0 ms 1096 KB Output is correct
3 Correct 0 ms 1096 KB Output is correct
4 Correct 0 ms 1096 KB Output is correct
5 Correct 0 ms 1096 KB Output is correct
6 Correct 0 ms 1096 KB Output is correct
7 Correct 0 ms 1096 KB Output is correct
8 Correct 0 ms 1096 KB Output is correct
9 Correct 0 ms 1096 KB Output is correct
10 Correct 0 ms 1096 KB Output is correct