| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 784855 | jakobrs | Type Printer (IOI08_printer) | C++17 | 124 ms | 105412 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using i64 = int64_t;
struct Node {
Node *children[26];
bool is_terminal = false;
i64 longest = 0;
i64 go_here_last = -1;
Node() { std::fill(std::begin(children), std::end(children), nullptr); }
};
void dfs(Node *node, i64 &w) {
if (node->is_terminal) {
std::cout << "P\n";
w--;
}
for (i64 i = 0; i < 26; i++) {
if (i != node->go_here_last && node->children[i]) {
std::cout << (char)(i + 'a') << '\n';
dfs(node->children[i], w);
if (w)
std::cout << "-\n";
}
}
if (node->go_here_last != -1) {
std::cout << (char)(node->go_here_last + 'a') << '\n';
dfs(node->children[node->go_here_last], w);
if (w)
std::cout << "-\n";
}
}
int main() {
i64 n;
std::cin >> n;
Node root;
i64 op_count = 0;
std::string word;
for (i64 i = 0; i < n; i++) {
word.clear();
std::cin >> word;
Node *cur = &root;
for (char ch : word) {
if (word.size() > cur->longest) {
cur->go_here_last = ch - 'a';
cur->longest = word.size();
}
if (!cur->children[ch - 'a']) {
cur->children[ch - 'a'] = new Node();
op_count += 2;
}
cur = cur->children[ch - 'a'];
}
cur->is_terminal = true;
op_count += 1;
}
op_count -= root.longest;
std::cout << op_count << '\n';
i64 w = n;
dfs(&root, w);
}
컴파일 시 표준 에러 (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... | ||||
