# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
522496 | Jesus | Type Printer (IOI08_printer) | C++14 | 429 ms | 61848 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
char ans[5000000];
struct arbol{
char letra;
int palabra_mayor;
bool fin_palabra=false;
int hijos[28];
};
string mayor;
int aux,desocupado=1;
arbol raices[500002];
void res(int pos, bool rama){
if(pos!=0) {
ans[aux]=raices[pos].letra;
aux++;
}
if(raices[pos].fin_palabra==true) {
ans[aux]='P';
aux++;
}
int m=-1;
for(int i=0;i<28;i++){
if(raices[pos].hijos[i]!=0){
if(desocupado<mayor.size()&&raices[raices[pos].hijos[i]].letra==mayor[desocupado]) {
m=i;
desocupado++;
}
else res(raices[pos].hijos[i],false);
}
}
if(pos==0&&m!=-1) res(raices[pos].hijos[m],true);
else if(m!=-1) res(raices[pos].hijos[m],rama);
if(pos!=0&&rama==false) {
ans[aux]='-';
aux++;
}
}
int main()
{
ios_base::sync_with_stdio();cin.tie(0);
int n;
cin>>n;
string palabra;
for(int i=0;i<n;i++){
cin>>palabra;
if(palabra.size()>mayor.size()) mayor=palabra;
aux=0;
for(char l:palabra){
if(raices[aux].hijos[l-'a']!=0) aux=raices[aux].hijos[l-'a'];
else{
raices[aux].hijos[l-'a']=desocupado;
aux=desocupado;
raices[aux].letra=l;
desocupado++;
}
}
raices[aux].fin_palabra=true;
}
desocupado=0;
aux=0;
res(0,false);
cout<<aux<<endl;
for(int i=0;i<aux;i++){
cout<<ans[i]<<endl;
}
return 0;
}
컴파일 시 표준 에러 (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... |