Submission #1125573

#TimeUsernameProblemLanguageResultExecution timeMemory
1125573Trn115Type Printer (IOI08_printer)C11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second #define sz(v) (int) v.size() #define all(v) v.begin(), v.end() using namespace std; constexpr int N = 2e5+5; constexpr int M = 1e9+7; constexpr int inf = 1e18; struct Node { bool exist; int max_depth; Node *nxt[26]; Node() { exist = false; max_depth = 0; for (int i = 0; i < 26; ++i) nxt[i] = NULL; } }; struct Trie { Node *root; Trie() { root = new Node(); } void insert(string s) { Node *cur = root; for (char c : s) { int idx = c - 'a'; if (cur->nxt[idx] == NULL) cur->nxt[idx] = new Node(); cur = cur->nxt[idx]; cur->max_depth = max(cur->max_depth, sz(s)); } cur->exist = true; } } trie; int trie_max_depth; string res; void dfs(Node *v) { if (v->exist) { res.push_back('P'); } int abyss = -1; for (int i = 0; i < 26; ++i) { if (v->nxt[i] != NULL) { if (v->nxt[i]->max_depth == trie_max_depth) { abyss = i; } } } for (int i = 0; i < 26; ++i) { if (i == abyss) continue; if (v->nxt[i] != NULL) { res.push_back(i + 'a'); dfs(v->nxt[i]); res.push_back('-'); } } if (abyss != -1) { res.push_back(abyss + 'a'); dfs(v->nxt[abyss]); res.push_back('-'); } } signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; while (n--) { string s; cin >> s; trie_max_depth = max(trie_max_depth, sz(s)); trie.insert(s); } dfs(trie.root); while (res.back() == '-') res.pop_back(); cout << res.size() << "\n"; for (char c : res) cout << c << "\n"; }

Compilation message (stderr)

printer.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.