| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 441579 | rainboy | Type Printer (IOI08_printer) | C11 | 58 ms | 17860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#define N 25000
#define L 20
#define N_ (2 + N * L)
#define A 26
int max(int a, int b) { return a > b ? a : b; }
int tt[N_][A], dd[N_]; char word[N_];
void dfs1(int i) {
int a;
for (a = 0; a < A; a++) {
int j = tt[i][a];
if (j) {
dfs1(j);
dd[i] = max(dd[i], dd[j] + 1);
}
}
}
void dfs2(int i) {
int a, a_;
if (word[i])
printf("P\n");
a_ = -1;
for (a = 0; a < A; a++) {
int j = tt[i][a];
if (j && dd[i] == dd[j] + 1) {
a_ = a;
break;
}
}
for (a = 0; a < A; a++) {
int j = tt[i][a];
if (j && a != a_) {
printf("%c\n", a + 'a');
dfs2(j);
printf("-\n");
}
}
if (a_ != -1) {
printf("%c\n", a_ + 'a');
dfs2(tt[i][a_]);
}
}
int main() {
int n, n_, i;
scanf("%d", &n);
n_ = 2;
for (i = 0; i < n; i++) {
static char cc[L + 1];
int l, h, t;
scanf("%s", cc), l = strlen(cc);
for (h = 0, t = 1; h < l; h++) {
int a = cc[h] - 'a';
if (!tt[t][a])
tt[t][a] = n_++;
t = tt[t][a];
}
word[t] = 1;
}
dfs1(1);
printf("%d\n", n + (n_ - 2) * 2 - dd[1]);
dfs2(1);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
