Submission #1098152

#TimeUsernameProblemLanguageResultExecution timeMemory
1098152rayan_bdType Printer (IOI08_printer)C++17
10 / 100
162 ms124100 KiB
#include <bits/stdc++.h> using namespace std; const int INF = (int)1e9; vector<char> ans; struct Node { Node *children[26]; bool end; int mnLen; set<pair<int, char>> st; char mnC; Node() { for (int i = 0; i < 26; ++i) children[i] = NULL; end = 0; mnLen = INF; mnC = '*'; }; }; Node *root = new Node(); struct Trie { void insert(string str) { Node *curr_node = root; for (auto it : str) { if (curr_node->children[it - 'a'] == NULL) { curr_node->children[it - 'a'] = new Node(); } vector<int> for_del; for (auto itt : curr_node->st) { if (itt.second == it) { for_del.push_back(itt.first); } } for (auto itt : for_del) curr_node->st.erase({itt, it}); curr_node->st.insert({(int)str.size(), it}); curr_node = curr_node->children[it - 'a']; } curr_node->end = 1; } void qry(Node *curr) { bool flag = 1; for (int i = 0; i < 26; ++i) { if (curr->children[i] != NULL) { flag = 0; } } if (curr->end == 1) { ans.push_back('P'); } if (flag) { ans.push_back('-'); return; } for (auto it : curr->st) { ans.push_back(it.second); qry(curr->children[it.second - 'a']); } ans.push_back('-'); } } t; void solve() { int n; cin >> n; string str; for (int i = 0; i < n; ++i) { cin >> str; t.insert(str); } Node *curr_node = root; t.qry(curr_node); int deletee = 0; for (int i = ans.size() - 1; i >= 0; --i) { if (ans[i] == '-') { ++deletee; } else { break; } } cout << ans.size() - deletee << '\n'; for (int i = 0; i < ans.size() - deletee; ++i) { cout << ans[i] << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }

Compilation message (stderr)

printer.cpp: In function 'void solve()':
printer.cpp:106:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |     for (int i = 0; i < ans.size() - deletee; ++i)
      |                     ~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...