# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57725 | 2018-07-15T22:59:19 Z | vex | Type Printer (IOI08_printer) | C++14 | 1000 ms | 99232 KB |
#include <bits/stdc++.h> #define MAXN 25005 #define ALPH 26 using namespace std; int br=1; struct Node{ bool in; bool kraj; struct Node* deca[ALPH]; }* head; void init() { head=new Node(); head->kraj=false; head->in=false; } int maxx=0; string naj; void ubaci(string s) { Node* curr=head; for(int i=0;i<s.size();i++) { if(maxx<s.size()) { maxx=s.size(); naj=s; } int zn=s[i]-'a'; if(curr->deca[zn]==NULL) { curr->deca[zn]=new Node(); curr->deca[zn]->kraj=false; curr->deca[zn]->in=false; br++; } curr=curr->deca[zn]; } curr->kraj=true; } void sredi() { Node* curr=head; curr->in=true; for(int i=0;i<maxx;i++) { int zn=naj[i]-'a'; curr=curr->deca[zn]; curr->in=true; } } void ispisi(Node* v) { if(v->kraj)cout<<"P"<<endl; int ind=-1; for(int i=0;i<ALPH;i++)if(v->deca[i]!=NULL) { Node* nv=v->deca[i]; if(nv->in)ind=i; else { cout<<char('a'+i)<<endl; ispisi(nv); cout<<"-"<<endl; } } if(ind!=-1) { cout<<char('a'+ind)<<endl; ispisi(v->deca[ind]); } } int n; string x; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); init(); cin>>n; for(int i=0;i<n;i++) { cin>>x; ubaci(x); } sredi(); cout<<2*br-2+n-maxx<<endl; ispisi(head); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 412 KB | Output is correct |
2 | Correct | 2 ms | 572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 572 KB | Output is correct |
2 | Correct | 2 ms | 572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 572 KB | Output is correct |
2 | Correct | 2 ms | 572 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 596 KB | Output is correct |
2 | Correct | 14 ms | 1376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 27 ms | 1992 KB | Output is correct |
2 | Correct | 30 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 6404 KB | Output is correct |
2 | Correct | 181 ms | 12784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 251 ms | 14948 KB | Output is correct |
2 | Correct | 66 ms | 14948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 616 ms | 36684 KB | Output is correct |
2 | Execution timed out | 1070 ms | 83548 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 499 ms | 83548 KB | Output is correct |
2 | Execution timed out | 1085 ms | 99232 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |