Submission #1093856

# Submission time Handle Problem Language Result Execution time Memory
1093856 2024-09-27T18:28:55 Z lambd47 Type Printer (IOI08_printer) C++14
0 / 100
45 ms 54868 KB
#include<bits/stdc++.h>
using namespace std;

const int MX=5e5+1;

int trie[MX][27];
char letra[MX];
bool ultimo[MX];
int tempo=0;

void add(string s, bool flag){
    int idat=0;
    for(auto c: s){
        int nat=c-'a';
        if(trie[idat][nat]!=-1){
            idat=trie[idat][nat];
        }
        else{
            trie[idat][nat]=++tempo;
            idat=tempo;
            letra[idat]=c;
        }
        if(flag)ultimo[idat]=1;
    }
}
int n;
bool acabou=0;
int cnt=0;
void dfs(int node){
    if(node!=0)cout<<letra[node]<<"\n";
    int esp=-1;
    bool folha=1;
    for(int i=0;i<26;i++){
        if(trie[node][i]==-1)continue;
        folha=0;
        if(ultimo[trie[node][i]]){
            esp=trie[node][i];
            continue;
        }
        dfs(trie[node][i]);
    }
    if(esp!=-1){
        dfs(esp);
    }
    if(folha){cout<<"P\n";cnt++;}
    if(cnt!=n && !ultimo[node])cout<<"-\n";
}



int main(){
    cin>>n;
    for(int i=0;i<MX;i++){
        for(int j=0;j<27;j++)trie[i][j]=-1;
    }
    vector<string> vec(n);
    int especial=0;
    int maior=0;
    for(int i=0;i<n;i++){cin>>vec[i];
        if(maior<vec[i].size()){
            maior=vec[i].size();
            especial=i;
        }
    }
    for(int i=0;i<n;i++){
        if(especial==i){
            add(vec[i],1);
        }
        else{
            add(vec[i],0);
        }
    }
    cout<<2*(tempo)-maior+n;
    dfs(0);



}

Compilation message

printer.cpp: In function 'int main()':
printer.cpp:60:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |         if(maior<vec[i].size()){
      |            ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 53072 KB Expected integer, but "20t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 53212 KB Expected integer, but "142e" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 53088 KB Expected integer, but "201h" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 53088 KB Expected integer, but "290b" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 53080 KB Expected integer, but "1193a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 53332 KB Expected integer, but "14145a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 53316 KB Expected integer, but "52541a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 53860 KB Expected integer, but "135477a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 54868 KB Expected integer, but "337528a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 54868 KB Expected integer, but "273585a" found
2 Halted 0 ms 0 KB -