# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
855098 | 2023-09-30T07:08:05 Z | vjudge1 | Type Printer (IOI08_printer) | C++14 | 195 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; const int sig=26,nn=25000; struct node{ int ch[sig]; bool mark,end; }t[nn*20]; int sz=0; void insert(const string& s){ int u=0; for(char c:s){ int d=c-'a',&cu=t[u].ch[d]; if(!cu) cu+=sz; u=cu; } t[u].end=true; } void dfs(int u,string& ans){ const node& x=t[u]; if(x.end) ans+='p'; int mi=-1; for(int i=0;i<sig;i++){ int v=x.ch[i]; if(!v) continue; if(t[v].mark) mi=i; else ans+=i+'a',dfs(v,ans); } if(mi=-1) ans+=mi+'a',dfs(x.ch[mi],ans); ans+='-'; } int main(){ int n; cin>>n; string s,l; for(int i=0;i<n;i++){ cin>>s,insert(s); if(s.length()>l.length()) l=s; } for(size_t i=0,u=0;i<l.size();i++) u=t[u].ch[l[i]-'a'],t[u].mark=true; s.clear(),dfs(0,s); while(s.back()=='-') s.pop_back(); cout<<s.size()<<'\n'; for(char c:s) cout<<c<<"\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 170 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 173 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 170 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 169 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 171 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 167 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 185 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 195 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 180 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 183 ms | 262144 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |