# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730700 | lucri | Type Printer (IOI08_printer) | C++17 | 126 ms | 53988 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |