분류 전체보기 177

[Python][SWEA] 6808. 규영이와 인영이의 카드게임

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이def permutation() : # 인영이 카드의 모든 조합을 인영이 카드와 비교 global cnt if len(card_lst) == 9 : sum = 0 for i in range(9): if lst_gu[i] > card_lst[i]: sum += (lst_gu[i] + card_lst[i]) if sum >= 86 : cnt += 1 break ..

[Python][SWEA] 1225. [S/W 문제해결 기본] 7일차 - 암호생성기 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이from collections import dequefor tc in range(1,11) : N = int(input()) lst = list(map(int,input().split())) q = deque() # queue 자료 구조를 이용 for ls in lst : q.append(ls) cnt = 0 # 1~5씩 숫자를 높여가면서 queue에 뺄셈 while q[-1] : # Queue의 맨 마지막이 0이 되는 경우 종료 cnt += 1 ..

[Python][SWEA] 1240. [S/W 문제해결 응용] 1일차 - 단순 2진 암호코드 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이#--------------------------------------------------------# 아이디어 정리# 0. 2진 코드 딕셔너리 형태로 생성# 1. 행의 합이 0인것 제외하고 0이 아닌 첫 행 추출 (for-if)# 2. 뒤에서 부터 1이 나오는 인덱스 위치부터 -56개까지 추출 (for)# 3. 56비트를 7비트씩 8개로 쪼개고, 딕셔너리에서 value값 추출 (for)# 4. 올바른 코드인지 체크 (for)#--------------------------------------------------------# 시간 복잡도 #..

[Python][SWEA] 1493. 수의 새로운 연산 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️ 파이썬 코드 풀이i = j = 1dic = {(i,j) : 1} # 인덱스 위치 -> 좌표값u_dic = {1 : (i,j)} # 좌표값 -> 인덱스 위치for n in range(2,50000) : # 인덱스 위치,좌표값 딕셔너리 형태로 생성 i -= 1 j += 1 if i == 0 : i = j j = 1 dic[(i,j)] = n u_dic[n] = (i,j)T = int(input())for tc in range(1,T+1) : p,q = list(map(int,input(..

[Python][SWEA] 1946. 간단한 압축 풀기 D2

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N = int(input()) lst = [(input().split()) for _ in range(N)] # 입력 받기 for i in range(N) : # 숫자형으로 변환 lst[i][1] = int(lst[i][1]) sentence = "" for char,num in lst : # 문자 * 숫자로 문자열 만들고 합치기 sentence += char * num print(f"#{tc}") # 너비..

[Python][SWEA] 4615. 재미있는 오셀로 게임 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N,M = map(int,input().split()) lst = [list(map(int,input().split())) for _ in range(M)] # 오셀로 기본 세팅 othello = [[0] * (N+1) for _ in range(N+1)] center = N//2 othello[center][center] = othello[center+1][center+1] = 2 othello[center+1][center] = oth..

[Python][SWEA] S/W 문제해결 기본 3일차 - 회문2 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗒️파이썬 코드 풀이for tc in range(1,11) : T = int(input()) lst = [] lst = [list(input()) for _ in range(100)] lst_v = [] # 세로->가로 전환 리스트 for j in range(100): tmp = [] for i in range(100): tmp.append(lst[i][j]) lst_v.append(tmp) mx = 1 for i in range(100) : # 1~100개 ..

[Python][SWEA] 1860. 진기의 최고급 붕어빵 D3

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com 🗒️파이썬 코드 풀이T = int(input())for tc in range(1,T+1) : N,M,K = map(int,input().split()) lst = list(map(int,input().split())) ans = "Possible" lst.sort() cnt = 0 for t in lst : cnt += 1 if (t//M)*K  1. 기본값은 Possible로 한다 2. 크기순으로 sort 정렬을 해준다. (먼저 오는 손님에게 붕어빵 먼저 제공) 3. 손님들의 도착시간 리스트..

[Python][SWEA] 1249. [S/W 문제해결 응용] 4일차 - 보급로 D4

SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com🗝️ DFS / BFS 와 STACK / QUEUE1. DFS- 스택,재귀 함수를 이용해서 구현 (일반적으로 재귀함수 사용)- 노드를 인접 노드가 없을때까지 스택에 넣음- 방문 처리가 완료되면 스택에서 최상단 노드를 꺼냄  1. BFS- 그래프에 가까운 노드부터 우선 탐색- 큐(Queue) 자료구조 사용  🗒️파이썬 코드 풀이from collections import dequeT = int(input())for tc in range(1,T+1): N = int(input()) lst = [] lst = [list(map(int,input())) fo..