일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 파이썬
- 2909
- 라즈베리파이
- 라즈베리파이3
- 알고리즘
- Crawling
- ubuntu
- NAV
- HTML
- 16.04
- springboot3.x
- 13237
- 라즈비안
- 크롤링
- 트리
- 2579
- baekjun
- raspberrypi
- Algorythm
- Python
- dynaminprogramming
- 백준
- nav-tab
- node.js
- bootstrap
- dp
- CSS
- 라즈베리파이3b+
- algotythm
- MongoDB
Archives
- Today
- Total
목록2644 (1)
노트
[백준] 2644번 촌수계산 python
n = int(input()) a,b = map(int,input().split()) m = int(input()) relation = [[0]*101 for _ in range(101)] visited = [0]*101 q = [] for i in range(m): x,y = map(int,input().split()) relation[x][y]=relation[y][x]=1 def dfs(): visited[a]=1 q.append(a) while q: k = q.pop(0) if k==b: return for j in range(1,n+1): if relation[k][j]==1 and visited[j]==0: visited[j]=visited[k]+1 q.append(j) dfs() if vis..
알고리즘
2023. 7. 1. 21:19