답안 #448530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448530 2021-07-30T12:32:49 Z rainboy Kartomat (COCI17_kartomat) C
80 / 80
1 ms 332 KB
#include <stdio.h>
#include <string.h>

#define N	50
#define L	100
#define A	26
#define N_	(2 + N * L)

int tt[N_][A];

int main() {
	static char cc[L + 1], keyboard[4][16];
	int n, n_, l, i, s, a;

	scanf("%d", &n);
	n_ = 2;
	while (n--) {
		scanf("%s", cc), l = strlen(cc);
		for (i = 0, s = 1; i < l; i++) {
			a = cc[i] - 'A';
			if (!tt[s][a])
				tt[s][a] = n_++;
			s = tt[s][a];
		}
	}
	scanf("%s", cc), l = strlen(cc);
	for (i = 0, s = 1; i < l; i++)
		s = tt[s][cc[i] - 'A'];
	keyboard[0][0] = keyboard[0][1] = keyboard[0][2] = '*';
	for (a = 0; a < A; a++)
		keyboard[(a + 3) / 8][(a + 3) % 8] = tt[s][a] ? a + 'A' : '*';
	keyboard[3][5] = keyboard[3][6] = keyboard[3][7] = '*';
	for (i = 0; i < 4; i++)
		printf("%s\n", keyboard[i]);
	return 0;
}

Compilation message

kartomat.c: In function 'main':
kartomat.c:15:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
kartomat.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%s", cc), l = strlen(cc);
      |   ^~~~~~~~~~~~~~~
kartomat.c:26:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%s", cc), l = strlen(cc);
      |  ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct