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

jenlog

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

jenlog

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

swea5178 (1)
[swea] 5178. 노드의 합 / python 파이썬

🚩 트리(tree) 풀이 1 왼쪽 자식, 오른쪽 자식을 세트로 같이 더해주는 방식 T = int(input()) for tc in range(1, T+1): N, M, L = map(int, input().split()) # N:노드개수, M:리드노프개수, L:출력할 노드번호 tree = [0 for _ in range(N + 1)] for i in range(M): n, v = map(int, input().split()) tree[n] = v # 방법1 if N % 2 == 0: # 노드개수가 짝수인 경우를 위해 설정 tree.append(0) for i in range((N//2)*2, 1, -2): tree[i // 2] = tree[i] + tree[i + 1] print("#{} {}".for..

algorithm/swea 2021. 4. 9. 01:12
이전 1 다음
이전 다음
글 보관함
TAG
  • dfs
  • git 미러링
  • 20057 마법사 상어와 토네이도
  • 영어끝말잇기
  • dp
  • 20056 마법사 상어와 파이어볼
  • 삼성기출
  • Python
  • 기지국설치
  • merge 에러
  • 보석쇼핑
  • 2018 카카오 공채
  • 프로그래머스
  • 2579 계단오르기
  • swea
  • 파이썬
  • 21609 상어 중학교
  • react
  • 백준
  • 알고리즘
  • 17406 배열돌리기4
  • 브루트포스
  • 삼성코테
  • merge에러
  • BFS
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

티스토리툴바