# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850696 | abcvuitunggio | Type Printer (IOI08_printer) | C++17 | 27 ms | 18772 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,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 (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... |