일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Python
- bootstrap
- ubuntu
- 라즈베리파이3
- algotythm
- 라즈베리파이
- HTML
- node.js
- 라즈베리파이3b+
- 알고리즘
- 백준
- Crawling
- dynaminprogramming
- 2579
- 16.04
- 크롤링
- raspberrypi
- baekjun
- nav-tab
- MongoDB
- dp
- 파이썬
- NAV
- 13237
- 라즈비안
- Algorythm
- 2909
- 트리
- springboot3.x
- CSS
- Today
- Total
목록Algorythm (15)
노트
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..
n, k = map(int, input().split()) kit = list(map(int, input().split())) used = [0] * n ans = 0 def dfs(a, weight): global ans if weight = n: ans += 1 return for i in range(n): if used[i] == 0: used[i] = 1 dfs(a + 1, weight + kit[i] - k) used[i] = 0 dfs(0, 500) print(ans)
import sys sys.setrecursionlimit(10 ** 6) a,b = map(int,input().split()) boss = list(map(int,input().split())) gujo = [[] for _ in range(a)] my_boss = [0]*(a+1) ans = [0]*(a+1) for i in range(1,a): if boss[i]!=-1: gujo[boss[i]].append(i+1) my_boss[i+1]=boss[i] def tamsaek(k): ans[k] += ans[my_boss[k]] if k