# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
477883 | 2021-10-04T10:48:16 Z | starplat | Type Printer (IOI08_printer) | C++14 | 126 ms | 48660 KB |
#include <bits/stdc++.h> using namespace std; vector<char> order,ans; int n,mxlen,ct,vis[550005]; string s,mxs; struct node{ int word,ac[30],go; }trie[550005]; void add(string x,bool ok) { int curr=0; for (int i=0;i<x.length();i++){ if (!trie[curr].ac[x[i]-'a']) trie[curr].ac[x[i]-'a']=++ct; curr=trie[curr].ac[x[i]-'a']; trie[curr].go=ok; } trie[curr].word=1; } void dfs(int curr,char c) { if (curr) ans.push_back(c); if (trie[curr].word) ans.push_back('P'); int dumb=0; for (int i=0;i<26;i++){ if (!trie[curr].ac[i]) continue; int node=trie[curr].ac[i]; if (trie[node].go) dumb=i; else { dfs(node,char(i+'a')); ans.push_back('-'); } } if (dumb){ dfs(trie[curr].ac[dumb],dumb+'a'); } } int main() { cin>>n; for (int i=0;i<n;i++){ cin>>s; if (s.length()>mxlen) mxlen=s.length(),mxs=s; add(s,0); } add(mxs,1); dfs(0,'1'); cout<<ans.size()<<"\n"; for (char c:ans) cout<<c<<"\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | didn't print every word |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 204 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1100 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 3532 KB | Output is correct |
2 | Correct | 18 ms | 7372 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 8704 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 21384 KB | Output is correct |
2 | Incorrect | 126 ms | 48660 KB | didn't print every word |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 49 ms | 16684 KB | didn't print every word |
2 | Halted | 0 ms | 0 KB | - |