Skip to content

Commit 8bd8b8a

Browse files
committed
solved 14725
1 parent 98c4c7d commit 8bd8b8a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

14000/14725/14725.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
typedef map<string, void*> node;
5+
6+
void printIndent(int depth){
7+
for(;depth>0;--depth) cout<<"--";
8+
}
9+
10+
void dfs(node root, int depth){
11+
for(auto iter: root){
12+
printIndent(depth);
13+
cout<<iter.first<<"\n";
14+
dfs(*(node*)iter.second, depth+1);
15+
}
16+
}
17+
18+
int main() {
19+
ios::sync_with_stdio(false); cin.tie(NULL);
20+
21+
int N, K;
22+
23+
node root;
24+
cin>>N;
25+
for(int i=0;i<N;++i){
26+
cin>>K;
27+
node *cur = &root;
28+
29+
for(int j=0;j<K;++j){
30+
string s;
31+
cin>>s;
32+
if(!(*cur)[s]) {(*cur)[s] = new node;}
33+
cur = (node*)(*cur)[s];
34+
}
35+
}
36+
37+
for(auto iter: root){
38+
cout<<iter.first<<"\n";
39+
dfs(*(node*)iter.second, 1);
40+
}
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)