Submission #1105343

#TimeUsernameProblemLanguageResultExecution timeMemory
1105343SwainTimeType Printer (IOI08_printer)C++14
0 / 100
64 ms38852 KiB
#include<bits/stdc++.h> using namespace std; vector<char> v; struct trie { int nr, rasp; trie *fii[27]; }; trie* init = new trie(); void add(trie *t, char *c) { t -> nr++; if(*c == '\0') { t -> rasp++; return; } if(t -> fii[*c - 'a'] == NULL) t -> fii[*c - 'a'] = new trie(); add(t -> fii[*c - 'a'], c + 1); } void ans(trie *t) { for(int i = 1; i <= t -> rasp; i++) v.push_back('P'); for(int i = 0; i < 26; i++) { if(t -> fii[i] != NULL) { v.push_back(char(i + 'a')); ans(t -> fii[i]); } } v.push_back('-'); } int main() { //freopen("trie.in", "r", stdin); //freopen("trie.out", "w", stdout); int n; char y[27]; cin >> n; for(int i = 1; i <= n; i++) { cin >> y; add(init, y); } ans(init); while(v.back() == '-') v.pop_back(); for(auto u : v) cout << u << "\n"; }
#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...