Skip to content

Commit

Permalink
58-9kyo-hwang
Browse files Browse the repository at this point in the history
  • Loading branch information
9kyo-hwang committed Jul 29, 2024
1 parent 8ccf421 commit 1f9f82f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 9-kyo-hwang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@
| 54차시 | 2024.7.04 | Data Structure | [16934 게임 닉네임](https://www.acmicpc.net/problem/16934) | [#197](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/197) |
| 55차시 | 2024.7.09 | Simulation | [17144 미세먼지 안녕!](https://www.acmicpc.net/problem/16934) | [#202](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/202) |
| 56차시 | 2024.7.12 | Tree | [15681 트리와 쿼리](https://www.acmicpc.net/problem/15681) | [#204](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/204) |
| 57차시 | 2024.7.15 | Dynamic Programming | [17070 파이프 옮기기 1](https://www.acmicpc.net/problem/17070) | [#206](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/206) |
| 57차시 | 2024.7.15 | Dynamic Programming | [17070 파이프 옮기기 1](https://www.acmicpc.net/problem/17070) | [#206](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/206) |
| 58차시 | 2024.7.29 | Trie | [14725 개미굴](https://www.acmicpc.net/problem/14725) | [#207](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/207) |
55 changes: 55 additions & 0 deletions 9-kyo-hwang/Trie/14725 개미굴.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <iostream>
#include <string>
#include <map>

using namespace std;

struct FNode
{
map<string, FNode*> Node;
};

FNode* Root;

void Print(FNode* InNode = Root, const string& Prefix="")
{
if(InNode == nullptr)
{
return;
}

for(const auto& [Data, Next] : InNode->Node)
{
cout << Prefix << Data << "\n";
Print(Next, Prefix + "--");
}
}

int main()
{
cin.tie(nullptr)->sync_with_stdio(false);

Root = new FNode();

int N; cin >> N;
for(int n = 0; n < N; ++n)
{
FNode* Ptr = Root;

int K; cin >> K;
for(int k = 0; k < K; ++k)
{
string Info; cin >> Info;
if(Ptr->Node.count(Info) == 0)
{
Ptr->Node[Info] = new FNode();
}

Ptr = Ptr->Node[Info];
}
}

Print();

return 0;
}

0 comments on commit 1f9f82f

Please sign in to comment.