We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98c4c7d commit 8bd8b8aCopy full SHA for 8bd8b8a
14000/14725/14725.cpp
@@ -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
38
39
+ dfs(*(node*)iter.second, 1);
40
41
42
+ return 0;
43
0 commit comments