#include<bits/stdc++.h>
using namespace std;
const int lmt=1e6;
int adj[lmt][26];
int root[lmt];
int indx=1;
bool vis[lmt];
int cnt=0;
void insert(string s,int now)
{
for(char c:s)
{
int num=c-'a';
if(!adj[now][num])
{
indx++;
root[indx]=now;
adj[now][num]=indx;
now=indx;
//cross[now]++;
}
else
{
now=adj[now][num];
//cross[now]++;
}
}
}
void dfs(int u)
{
if(vis[u]==0)
{
cnt++;
vis[u]=1;
}
bool on=1;
for(int i=0;i<26;i++)
{
if(adj[u][i]!=0)
{
on=0;
char c='a'+i;
cout<<c<<endl;
dfs(adj[u][i]);
}
}
if(on) cout<<'P'<<endl;
if(cnt<indx) cout<<'-'<<endl;
}
int main()
{
//#ifndef ONLINE_JUDGE
// freopen("take.in","r",stdin);
// freopen("give.out","w",stdout);
//#endif
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
string s;
cin>>s;
insert(s,1);
}
dfs(1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Expected integer, but "t" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Expected integer, but "e" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Expected integer, but "h" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Expected integer, but "b" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
384 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
1024 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
116 ms |
3072 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
270 ms |
7416 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
702 ms |
18124 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
569 ms |
14244 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |