답안 #60941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60941 2018-07-25T03:54:58 Z 0xrgb 고장난 휴대전화기 (COCI14_mobitel) C++11
50 / 50
2 ms 756 KB
#include <cstdio>

int D[10];
char msg[128];
constexpr int T[][2] = {
	{2, 1}, {2, 2}, {2, 3},
	{3, 1}, {3, 2}, {3, 3},
	{4, 1}, {4, 2}, {4, 3},
	{5, 1}, {5, 2}, {5, 3},
	{6, 1}, {6, 2}, {6, 3},
	{7, 1}, {7, 2}, {7, 3}, {7, 4},
	{8, 1}, {8, 2}, {8, 3},
	{9, 1}, {9, 2}, {9, 3}, {9, 4},
};


int main() {
	for (int i = 1; i <= 9; ++i) {
		int x;
		scanf("%d", &x);
		D[x] = i;
	}
	scanf("%s", msg);

	for (int i = 0; msg[i]; ++i) {
		const int ma = msg[i] - 'a';
		if (i >= 1 && T[ma][0] == T[msg[i - 1] - 'a'][0]) putchar('#');
		for (int i = 0, j = T[ma][1], k = D[T[ma][0]]; i < j; ++i) putchar('0' + k);
	}
	puts("");
}

Compilation message

mobitel.cpp: In function 'int main()':
mobitel.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
mobitel.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", msg);
  ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 580 KB Output is correct
10 Correct 2 ms 756 KB Output is correct