-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from yuna83/31-yuna83
31-yuna83
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters