From ef1ce55cc749ed74491d8ffa63d4c85a3a4075cd Mon Sep 17 00:00:00 2001 From: sh0723 Date: Mon, 7 Sep 2026 17:01:16 +0900 Subject: [PATCH] =?UTF-8?q?5913=20:=20=EC=B9=9C=EA=B5=AC=EC=9D=98=20?= =?UTF-8?q?=EC=B9=9C=EA=B5=AC=EB=8A=94=20=EC=B9=9C=EA=B5=AC=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/JungOl/JO5913/JO5913_V1.cpp | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/JungOl/JO5913/JO5913_V1.cpp diff --git a/src/JungOl/JO5913/JO5913_V1.cpp b/src/JungOl/JO5913/JO5913_V1.cpp new file mode 100644 index 0000000..04482f0 --- /dev/null +++ b/src/JungOl/JO5913/JO5913_V1.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; +int used[501]; +vector> friends(501, vector()); +int cnt = 0; + +void dfs(int n, int level) { + for (int num : friends[n]) { + if (level < 3 && num != 1 && used[num] == 0) { + cnt ++; + used[num] = 1; + dfs(num, level+1); + } + } +} + +int main() { + + ios_base::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + + int N,M; + cin >> N >> M; + + + for (int i=0; i> a >> b; + friends[a].push_back(b); + friends[b].push_back(a); + } + + dfs(1,1); + + cout << cnt; + return 0; +} \ No newline at end of file