Submission #392818

# Submission time Handle Problem Language Result Execution time Memory
392818 2021-04-21T21:01:59 Z rainboy Mobitel (COCI14_mobitel) C
50 / 50
1 ms 208 KB
#include <stdio.h>
#include <string.h>

#define N	100

int aa[] = { 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9 };
int kk[] = { 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4 };

int main() {
	static int ii[10];
	static char cc[N + 1], ans[N * 5 + 1];
	int n, h, i, cnt;

	for (i = 1; i <= 9; i++) {
		int a;

		scanf("%d", &a);
		ii[a] = i;
	}
	scanf("%s", cc), n = strlen(cc);
	cnt = 0;
	for (i = 0; i < n; i++) {
		int c = cc[i] - 'a';

		if (i > 0 && aa[c] == aa[cc[i - 1] - 'a'])
			ans[cnt++] = '#';
		for (h = 0; h < kk[c]; h++)
			ans[cnt++] = ii[aa[c]] + '0';
	}
	printf("%s\n", ans);
	return 0;
}

Compilation message

mobitel.c: In function 'main':
mobitel.c:17:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   17 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
mobitel.c:20:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%s", cc), n = strlen(cc);
      |  ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct