2024/05/04 4

[Python][SWEA] 2814. 최장 경로 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N,M = map(int,input().split()) # 정점 개수, 간선 정보 ans = 0 adjL = [[] * m for m in range(N+1)] # 정점별 연결 되어있는 것 체크 리스트 for m in range(M): # s,e 변수들끼리 서로 연결 s,e = map(int,input().split()) adjL[s].append(e) adjL[e].append(s) def df..

[Python][SWEA] 2817. 부분 수열의 합 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N,K = map(int,input().split()) lst = list(map(int,input().split())) ans,sum,n = 0,0,0 def dfs(n,sum) : global ans if sum == K : # 총 합이 K 일때 ans += 1 return if n >= N: # n이 배열 크기만큼 도달 할 경우 return ..

[Python][SWEA] 959. 두 개의 숫자열 D2

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1): N,M = map(int,input().split()) # M,N 각각 입력 N_lst = list(map(int,input().split())) # N 리스트 입력 M_lst = list(map(int,input().split())) # M 리스트 입력 result = [] diff_len = abs(N-M) # M과 N 배열의 길이 차이 if N >= M: # N과 M 중 작은 배열의 크기를 큰 배열 크기만큼 0로 채워주기 ..

[Python][SWEA] 3752. 가능한 시험 점수 D4

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1): N = int(input()) lst = list(map(int,input().split())) # 입력값 result = [0] # 결과값 저장 visit = [1] + [0] * sum(lst) # 방문 체크 for i in range(len(lst)) : for j in range(len(result)): if visit[lst[i]+result[j]] == 0 : # 방문은 안했을 경우 ..