일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 파이썬
- ubuntu
- node.js
- 라즈베리파이3
- NAV
- dp
- 16.04
- 2579
- 13237
- HTML
- 라즈베리파이
- nav-tab
- bootstrap
- springboot3.x
- algotythm
- CSS
- MongoDB
- 트리
- raspberrypi
- 2909
- 라즈비안
- 알고리즘
- Crawling
- 라즈베리파이3b+
- dynaminprogramming
- baekjun
- Python
- Algorythm
- 크롤링
- 백준
- Today
- Total
목록알고리즘 (23)
노트
n = int(input()) tree = {} for _ in range(n): root, left, right = input().split() tree[root] = [left,right] def preorder(a): if a is not '.': print(a,end='') preorder(tree[a][0]) preorder(tree[a][1]) def inorder(a): if a is not '.': inorder(tree[a][0]) print(a,end='') inorder(tree[a][1]) def postorder(a): if a is not '.': postorder(tree[a][0]) postorder(tree[a][1]) print(a,end='') preorder('A') ..
n,m = map(int,input().split()) cards = list(map(int,input().split())) ans = 0 for i in range(m): cards.sort() temp = cards[0]+cards[1] cards[0] = cards[1] = temp for j in range(n): ans += cards[j] print(ans)
n = int(input()) for i in range(n): floor = int(input()) room = int(input()) f0 = [i for i in range(1,room+1)] for j in range(floor): for k in range(1,room): f0[k] += f0[k - 1] print(f0[room-1])
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..