#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define INF 1000000000
#define LINF 1000000000000000LL
#define pb push_back
#define all(x) x.begin(), x.end()
#define len(s) (int)s.size()
#define test_case { int t; cin>>t; while(t--)solve(); }
#define input(n, v) {for(int i = 0;i<n;i++) cin>>v[i];}
#define output(n, v) {for(int i = 0;i<n;i++) cout<<v[i]<<" "; cout<<endl;}
#define single_case solve();
#define line cout<<"------------"<<endl;
#define ios { ios_base::sync_with_stdio(false); cin.tie(NULL); }
using namespace std;
const int N = 5e5 + 5;
int trie[N][26];
int kraj[N];
int ind;
int n;
int cnt = 0;
void _insert(string s)
{
int node = 0;
for(int i = 0;i<len(s);i++)
{
int c = s[i] - 'a';
if(!trie[node][c]) trie[node][c] = ++ind;
node = trie[node][c];
}
kraj[node] = 1;
}
void resi(int node)
{
if(kraj[node])
{
cout<<"P"<<endl;
cnt++;
}
for(int i = 0;i<26;i++)
{
if(trie[node][i])
cout<<char(i+'a')<<endl, resi(trie[node][i]);
}
if(cnt<n)
cout<<"-"<<endl;
}
int main()
{
ios
cin>>n;
for(int i = 0;i<n;i++)
{
string s;
cin>>s;
_insert(s);
}
resi(0);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Expected integer, but "t" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "e" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "h" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "b" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1132 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
3180 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
7404 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
18156 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
40 ms |
14316 KB |
Expected integer, but "a" found |
2 |
Halted |
0 ms |
0 KB |
- |