Submission #1002590

#TimeUsernameProblemLanguageResultExecution timeMemory
1002590vjudge1Type Printer (IOI08_printer)C++14
0 / 100
30 ms18636 KiB
#include <bits/stdc++.h> using namespace std; const int sz=5e5+1; int trie[sz][26]; int bitdi[sz]; int last=0,cnt=0; vector<char> cvb; int n; void qur(string s){ int curr=0; for(auto &i : s){ if(trie[curr][i - 'a'])curr = trie[curr][i - 'a']; else curr = trie[curr][i - 'a'] = ++last; } bitdi[curr]++; } void dfs(int node){ if(bitdi[node]){ for(int i=0;i<bitdi[node];++i)cvb.push_back('p'); cnt += bitdi[node]; } if(cnt == n)return; for(int i=0;i<26;++i){ if(trie[node][i]){ cvb.push_back(char('a' + i)); dfs(trie[node][i]); } } cvb.push_back('-'); } int main(){ cin >> n; string a; for(int i=0;i<n;++i){ cin >> a; qur(a); } dfs(0); cout << cvb.size() << '\n'; for(auto &i : cvb)cout << i << '\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...