Submission #676660

#TimeUsernameProblemLanguageResultExecution timeMemory
676660QwertyPiType Printer (IOI08_printer)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int SIGMA = 26; struct node{ node* nxt[SIGMA]; bool word = false; int heavy = -1; node() { fill(nxt, nxt + SIGMA, 0); } node* extend(int c){ if(!nxt[c]) nxt[c] = new node; return nxt[c]; } node* extend_heavy(int c){ heavy = c; return nxt[c]; } }; string ans; void dfs(node *root){ if(root->word) ans.push_back('P'); for(int c = 0; c < SIGMA; c++){ if(root->nxt[c] && root->heavy != c){ ans.push_back('a' + c); dfs(root->nxt[c]); ans.push_back('-'); } } if(root->heavy != -1){ ans.push_back('a' + root->heavy); dfs(root->nxt[root->heavy]); ans.push_back('-'); } } node *root = new node; int main(){ int n; cin >> n; vector<string> vs; for(int i = 0; i < n; i++){ string s; cin >> s; vs.push_back(s); node *x = root; for(auto c : s){ x = x->extend(c - 'a'); } x->word = true; } sort(vs.begin(), vs.end(), [](string a, string b){ return a.size() < b.size(); }); { node *x = root; for(auto c : vs.back()){ x = x->extend_heavy(c - 'a'); } } dfs(root); while(ans.back() == '-') ans.pop_back(); cout << ans.size() << '\n'; for(auto c : ans) cout << c << '\n'; }

Compilation message (stderr)

In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from printer.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = node**; _Tp = int; typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/10/bits/stl_algobase.h:914:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = node**; _Tp = int]'
/usr/include/c++/10/bits/stl_algobase.h:944:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = node**; _Tp = int]'
printer.cpp:11:27:   required from here
/usr/include/c++/10/bits/stl_algobase.h:873:13: error: invalid conversion from 'int' to 'node*' [-fpermissive]
  873 |  *__first = __tmp;
      |             ^~~~~
      |             |
      |             int