본문 바로가기 메뉴 바로가기

jenlog

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

jenlog

검색하기 폼
  • All (81)
    • algorithm (71)
      • baekjoon (31)
      • swea (30)
      • programmers (9)
    • JS (1)
    • Vue.js (2)
    • React (2)
    • * etc (5)
  • 방명록

swea5174 (1)
[swea] 5174. subtree / python 파이썬

🚩 트리(tree) 코드 T = int(input()) def size(root): global cnt if tree[root][0]: cnt += 1 size(tree[root][0]) if tree[root][1]: cnt += 1 size(tree[root][1]) for tc in range(1, T+1): E, N = map(int, input().split()) # 간선개수, root tmp = list(map(int, input().split())) # 부모-자식 tree = [[0] * 3 for _ in range(E+2)] for i in range(E): # [왼쪽자식, 오른쪽자식, 부모노드] parent, child = tmp[i * 2], tmp[i * 2 + 1] tree[chi..

algorithm/swea 2021. 4. 9. 00:49
이전 1 다음
이전 다음
글 보관함
TAG
  • 파이썬
  • 기지국설치
  • 20056 마법사 상어와 파이어볼
  • react
  • 21609 상어 중학교
  • 삼성코테
  • 20057 마법사 상어와 토네이도
  • 17406 배열돌리기4
  • 알고리즘
  • BFS
  • 2018 카카오 공채
  • 프로그래머스
  • 2579 계단오르기
  • 삼성기출
  • 백준
  • 보석쇼핑
  • swea
  • Python
  • merge에러
  • dp
  • dfs
  • 브루트포스
  • git 미러링
  • 영어끝말잇기
  • merge 에러
more
최근에 올라온 글
Total
Today
Yesterday
최근에 달린 댓글
«   2025/05   »
일 월 화 수 목 금 토
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

jennnn.tistory.com

티스토리툴바