# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
448530 | rainboy | Kartomat (COCI17_kartomat) | C11 | 1 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |