Submission #850696

# Submission time Handle Problem Language Result Execution time Memory
850696 2023-09-17T09:47:22 Z abcvuitunggio Type Printer (IOI08_printer) C++17
0 / 100
27 ms 18772 KB
#include <bits/stdc++.h>
using namespace std;
int n,id,ke[500001][26],d[500001],w[500001];
string s,t;
void add(){
    int cur=0;
    for (char c:s){
        if (!ke[cur][c-'a']){
            ke[cur][c-'a']=++id;
            d[id]=d[cur]+1;
        }
        cur=ke[cur][c-'a'];
    }
    w[cur]=1;
}
void dfs(int u, int b){
    for (int i=0;i<26;i++)
        if (!(b&&i==t[d[u]]-'a')&&ke[u][i]){
            cout << (char)(i+'a') << '\n';
            dfs(ke[u][i],0);
        }
    if (w[u])
        cout << "P\n";
    if (b){
        if (d[u]!=t.length()-1){
            cout << t[d[u]] << '\n';
            dfs(ke[u][t[d[u]]-'a'],1);
        }
    }
    else
        cout << "-\n";
}
int main(){
    ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> s;
        add();
        if (t.length()<s.length())
            t=s;
    }
    t+=' ';
    dfs(0,1);
}

Compilation message

printer.cpp: In function 'void dfs(int, int)':
printer.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if (d[u]!=t.length()-1){
      |             ~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Expected integer, but "t" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Expected integer, but "e" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "h" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Expected integer, but "b" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1116 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 3160 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 7768 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 18772 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 14676 KB Expected integer, but "a" found
2 Halted 0 ms 0 KB -