Skip to content

Commit

Permalink
62-9kyo-hwang
Browse files Browse the repository at this point in the history
  • Loading branch information
9kyo-hwang committed Aug 12, 2024
1 parent 9208996 commit f754cc5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int Merge(vector<string>& Maps, int x, int y)
{
if(x < 0 || x >= Maps.size() || y < 0 || y >= Maps[0].size() || Maps[x][y] == 'X')
{
return 0;
}

int Day = Maps[x][y] - '0';
Maps[x][y] = 'X';

return Day
+ Merge(Maps, x - 1, y)
+ Merge(Maps, x, y + 1)
+ Merge(Maps, x + 1, y)
+ Merge(Maps, x, y - 1);
}

vector<int> solution(vector<string> Maps)
{
vector<int> DaysofStay;
for(int i = 0; i < Maps.size(); ++i)
{
for(int j = 0; j < Maps[0].size(); ++j)
{
if(Maps[i][j] != 'X')
{
DaysofStay.emplace_back(Merge(Maps, i, j));
}
}
}

if(DaysofStay.empty())
{
return {-1};
}

sort(DaysofStay.begin(), DaysofStay.end());
return DaysofStay;
}
3 changes: 2 additions & 1 deletion 9-kyo-hwang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@
| 58์ฐจ์‹œ | 2024.7.29 | Trie | [14725 ๊ฐœ๋ฏธ๊ตด](https://www.acmicpc.net/problem/14725) | [#207](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/207) |
| 59์ฐจ์‹œ | 2024.8.01 | Greedy | [๋งˆ๋ฒ•์˜ ์—˜๋ฆฌ๋ฒ ์ดํ„ฐ](https://school.programmers.co.kr/learn/courses/30/lessons/148653) | [#210](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/210) |
| 60์ฐจ์‹œ | 2024.8.05 | Implementation | [๊ณผ์ œ ์ง„ํ–‰ํ•˜๊ธฐ](https://school.programmers.co.kr/learn/courses/30/lessons/176962) | [#213](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/213) |
| 60์ฐจ์‹œ | 2024.8.08 | Implementation | [ํ…Œ์ด๋ธ” ํ•ด์‹œ ํ•จ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/147354) | [#214](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/214) |
| 61์ฐจ์‹œ | 2024.8.08 | Implementation | [ํ…Œ์ด๋ธ” ํ•ด์‹œ ํ•จ์ˆ˜](https://school.programmers.co.kr/learn/courses/30/lessons/147354) | [#214](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/214) |
| 62์ฐจ์‹œ | 2024.8.12 | Graph Traversal | [๋ฌด์ธ๋„ ์—ฌํ–‰](https://school.programmers.co.kr/learn/courses/30/lessons/154540) | [#217](https://github.com/AlgoLeadMe/AlgoLeadMe-3/pull/217) |

0 comments on commit f754cc5

Please sign in to comment.