# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850698 | 2023-09-17T09:50:12 Z | abcvuitunggio | Type Printer (IOI08_printer) | C++17 | 71 ms | 50776 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; } cout << id*2-t.length()+n << '\n'; t+=' '; dfs(0,1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 0 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 600 KB | Output is correct |
2 | Correct | 1 ms | 1112 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1112 KB | Output is correct |
2 | Correct | 2 ms | 1368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3160 KB | Output is correct |
2 | Correct | 8 ms | 6488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 7512 KB | Output is correct |
2 | Correct | 4 ms | 1880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 18512 KB | Output is correct |
2 | Correct | 60 ms | 42632 KB | Output is correct |
3 | Correct | 32 ms | 22124 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 14556 KB | Output is correct |
2 | Correct | 71 ms | 50776 KB | Output is correct |
3 | Correct | 36 ms | 25168 KB | Output is correct |
4 | Correct | 58 ms | 47900 KB | Output is correct |