일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- Algorythm
- 13237
- CSS
- HTML
- 알고리즘
- node.js
- dynaminprogramming
- ubuntu
- 16.04
- dp
- 트리
- raspberrypi
- 파이썬
- 크롤링
- NAV
- 백준
- 2909
- baekjun
- 라즈베리파이3
- bootstrap
- 라즈베리파이3b+
- MongoDB
- algotythm
- springboot3.x
- 라즈비안
- Python
- nav-tab
- 라즈베리파이
- Crawling
- 2579
- Today
- Total
목록2023/07 (5)
노트
from collections import deque def bfs(node): queue = deque() queue.append(node) while queue: node = queue.popleft() for n in friend[node]: if check[n] == 0: check[n] = check[node]+1 queue.append(n) n = int(input()) m = int(input()) friend = [[] for _ in range(n+1)] for j in range(m): a,b=map(int,input().split(' ')) friend[a].append(b) friend[b].append(a) check = [0]*(n+1) check[1] = 1 bfs(1) res..
n = int(input()) answer = 0 in_, out = dict(), [] for i in range(n): car = input() in_[car] = i for _ in range(n): car = input() out.append(car) for i in range(n - 1): for j in range(i + 1, n): if in_[out[i]] > in_[out[j]]: answer += 1 break print(answer)
3번이나 틀렸다고 나와서 뭐지 했는데 아이패드로 풀어서 예제 복사할때 줄바꿈이 안됐던거였다.. 데탑으로 푸니 잘됨 q = [] while True: s = input() if s=='.': break for i in range(len(s)): if s[i] == '.': if len(q) == 0: print('yes') else: print('no') q = [] continue if s[i] == '(' or s[i] == ')' or s[i] == '[' or s[i] == ']': q.append(s[i]) if len(q) > 0: if s[i] == ')' and q[len(q) - 2] == '(': q.pop() q.pop() if s[i] == ']' and q[len(q) - 2] ==..
v = int(input()) e = int(input()) graph = [[] for _ in range(v+1)] for _ in range(e): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) def dfs(x): global count visited[x] = True count += 1 for node in graph[x]: if visited[node]: continue dfs(node) count = 0 visited = [False for _ in range(v+1)] dfs(1) print(count-1)
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..