diff --git a/9-kyo-hwang/README.md b/9-kyo-hwang/README.md index 4ef3bc9..c576a7c 100644 --- a/9-kyo-hwang/README.md +++ b/9-kyo-hwang/README.md @@ -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) | \ No newline at end of file +| 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) | \ No newline at end of file diff --git "a/9-kyo-hwang/Trie/14725 \352\260\234\353\257\270\352\265\264.cpp" "b/9-kyo-hwang/Trie/14725 \352\260\234\353\257\270\352\265\264.cpp" new file mode 100644 index 0000000..9472230 --- /dev/null +++ "b/9-kyo-hwang/Trie/14725 \352\260\234\353\257\270\352\265\264.cpp" @@ -0,0 +1,55 @@ +#include +#include +#include + +using namespace std; + +struct FNode +{ + map 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; +} \ No newline at end of file