# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730700 | 2023-04-26T09:40:19 Z | lucri | Type Printer (IOI08_printer) | C++17 | 126 ms | 53988 KB |
#include <bits/stdc++.h> using namespace std; int n,a[650010][30],ans,nr; char lmax,c[25],cmax[25]; void adauga() { int l=strlen(c),nod=0; for(int i=0;i<l;++i) { if(a[nod][c[i]-'a']) nod=a[nod][c[i]-'a']; else { a[nod][c[i]-'a']=++nr; nod=nr; } } ++a[nod][26]; } void elimina(int str,int nod,bool rb) { for(int i=0;i<26;++i) { if(a[nod][i]&&(rb==false||rb==true&&i+'a'!=cmax[str])) { cout<<(char)(i+'a')<<'\n'; elimina(str+1,a[nod][i],false); } } while(a[nod][26]--) cout<<"P\n"; if(rb==true) { if(str<lmax) { cout<<cmax[str]<<'\n'; elimina(str+1,a[nod][cmax[str]-'a'],true); } } else cout<<"-\n"; } int main() { cin>>n; while(n--) { cin>>c; adauga(); ++ans; if(strlen(c)>lmax) { lmax=strlen(c); for(int i=0;i<lmax;++i) cmax[i]=c[i]; } } cout<<nr*2+ans-lmax<<'\n'; elimina(0,0,true); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 308 KB | Output is correct |
2 | Correct | 1 ms | 312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Output is correct |
2 | Correct | 1 ms | 724 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1108 KB | Output is correct |
2 | Correct | 3 ms | 1236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 3268 KB | Output is correct |
2 | Correct | 14 ms | 6868 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 7996 KB | Output is correct |
2 | Correct | 10 ms | 1988 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 19904 KB | Output is correct |
2 | Correct | 95 ms | 45408 KB | Output is correct |
3 | Correct | 60 ms | 23500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 15612 KB | Output is correct |
2 | Correct | 126 ms | 53988 KB | Output is correct |
3 | Correct | 66 ms | 26700 KB | Output is correct |
4 | Correct | 99 ms | 50984 KB | Output is correct |