From 00aec03ac0da9ee6633c22c489ad77a58ae03eb3 Mon Sep 17 00:00:00 2001 From: Yuna Date: Fri, 23 Feb 2024 10:14:24 +0900 Subject: [PATCH] 31-yuna83 --- ...24\354\235\264\353\237\254\354\212\244.py" | 21 +++++++++++++++++++ yuna83/README.md | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 "yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" diff --git "a/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 00000000..059ac612 --- /dev/null +++ "b/yuna83/DFS/\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,21 @@ +cnt=0 +def DFS(virus): + global cnt + visited[virus]=1 + + for i in network[virus]: + if (visited[i]==0): + DFS(i) + cnt+=1 + +N= int(input()) +link = int(input()) + +network = [[]*(N+1) for _ in range(N+1)] +for i in range(link): + a, b = map(int, input().split()) + network[a].append(b) + network[b].append(a) +visited = [0]*(N+1) +DFS(1) +print(cnt) diff --git a/yuna83/README.md b/yuna83/README.md index c77b7df2..68ecc54f 100644 --- a/yuna83/README.md +++ b/yuna83/README.md @@ -30,4 +30,7 @@ | 26차시 | 2024.01.30 | 딕셔너리 | [귤 고르기](https://school.programmers.co.kr/learn/courses/30/lessons/138476)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/125| | 27차시 | 2024.02.05 | 투포인터 | [좋다](https://www.acmicpc.net/problem/1253)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/129| | 28차시 | 2024.02.07 | 투포인터 | [구명보트](https://school.programmers.co.kr/learn/courses/30/lessons/42885)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/134| +| 29차시 | 2024.02.13 | 슬라이딩윈도우 | [블로그](https://www.acmicpc.net/problem/21921)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/136| +| 30차시 | 2024.02.19 | 슬라이딩윈도우 | [도둑](https://www.acmicpc.net/problem/13422)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/141| +| 31차시 | 2024.02.23 | DFS/BFS | [바이러스](https://www.acmicpc.net/problem/2606)|https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/145| ---