Submission #1186260

#TimeUsernameProblemLanguageResultExecution timeMemory
1186260AzeTurk810Type Printer (IOI08_printer)C++20
20 / 100
60 ms44172 KiB
// Telebe of adicto yani AzeTurk810 // // WHY ARE YOU STARING MY CODE Stranger ??!! // //GO AWAY AND DON T look my CODE if i don t know you or you are stalker !!!!(hrrr) // // here about me: I am alone of course, fun , ' , ' , love pyhcics , young(child) , love music , had birds , not a gamer , chess :) , dead to football , you are looking to code , ... ; // // why at 1 japon army march they say "the enemy geniral is a hero , an equal to no one. Both in glory and in victory // the men that follow him are also breave , fearless wariors ..."? #include <bits/stdc++.h> using namespace std; using ll = long long; # define ln '\n' # define ff first # define ss second # define INFll 1e17 string res; struct trie { vector<trie*> child; int finish = false; int nodess; trie() { child.assign(26 , nullptr); finish = false; nodess = 0; }; void print(trie *node) { if(node -> nodess == 1 && node -> finish == 1) { res.push_back('P'); res.push_back('-'); return; } while(node -> finish--) { res.push_back('P'); } vector<pair<int,char>> cur; for(int i = 0 ; i < 26 ; i++) { if(node -> child[i]) { cur.push_back({(node -> child[i]) -> nodess , char(i + 'a')}); } } sort(cur.begin() , cur.end()); for(int i = 0 ; i < cur.size() ; i ++ ) { res.push_back(cur[i].ss); print(node -> child[cur[i].ss - 'a']); } res.push_back('-'); } void ins(string &s) { trie *node = this; for(char c:s ) { int id = c - 'a'; if(!node -> child[id]) { node -> child[id] = new trie(); } node -> nodess++; node = node -> child[id]; } node -> nodess++; node -> finish++; } bool askk(int &k , int l) { trie *node = this; return query(k , l , node); } bool query(int &k , int l , trie *node) { bool ok = false; if(node -> nodess < k) return false; if(!l) { return node -> nodess >= k; } for(int i = 0 ; i < 26 ; i++) { if(node -> child[i]) { trie *cur = node -> child[i]; if(cur -> nodess >= k) { ok |= query(k , l - 1 , cur); } if(ok) return ok; } } return ok; } bool ask(string &s) { trie *node = this; for(char &c : s) { int id = c - 'a'; if(!node -> child[id]) return false; node = node -> child[id]; } return node -> finish; } void del(string &s) { trie *node = this; for(char &c : s){ int id = c - 'a'; node -> nodess--; node = node -> child[id]; } node -> nodess--; node -> finish--; } void print() { print(this); } }; void solve() { int q; cin >> q; trie root; string s; int ec = q; while(q--) { cin >> s; root.ins(s); } root.print(); int cnt = 0; q = ec; string ans; for(char &c: res) { if(c == 'P') cnt++; ans.push_back(c); if(cnt >= q) break; } cout << ans.size() << ln; for(char &c : ans) { cout << c << ln; } } signed main() { // build(); int t = 1; for(int cases = 1 ; cases <= t; cases++) { solve(); } }
#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...