# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151327 | 2019-09-02T13:11:04 Z | GioChkhaidze | Type Printer (IOI08_printer) | C++14 | 73 ms | 18896 KB |
#include <bits/stdc++.h> using namespace std; int n,M; string s[25005]; int Ts=1,T[25005*20][26]; bool Leaf[25005*36],f[25005*20]; void Add (int Id,int idx,int i) { int t=s[idx][i]-'a'; if (i==s[idx].size()) return ; if (!T[Id][t]) T[Id][t]=++Ts; if (i+1==s[idx].size()) Leaf[T[Id][t]]=1; Add(T[Id][t],idx,i+1); } void F(int Id,int i) { int t=s[M][i]-'a'; f[Id]=1; if (i==s[M].size()) return ; F(T[Id][t],i+1); } void Dfs (int Id,int i) { if (Leaf[Id]) printf("P \n"); int In=-1; for (int t=0; t<26; t++) if (T[Id][t]) if (f[T[Id][t]]) In=t; else { printf("%c\n",t+'a'); Dfs(T[Id][t],i+1); } if (In!=-1) { printf("%c\n",In+'a'); Dfs(T[Id][In],i+1); } if (!f[Id]) printf("- \n"); } main () { cin>>n; for (int i=1; i<=n; i++) { cin>>s[i]; if (i==1) M=i; else if (s[i].size()>s[M].size()) M=i; Add(1,i,0); } F(1,0); printf("%d\n",(Ts-1)*2-s[M].size()+n); Dfs(1,0); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1184 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1144 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1144 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1144 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 1144 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 1916 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 3832 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 8056 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 73 ms | 18896 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 14836 KB | Line "P " doesn't correspond to pattern "[a-z\-P]{1}" |
2 | Halted | 0 ms | 0 KB | - |