[SW Expert Academy]1249. [S/W 문제해결 응용] 4일차 - 보급로
·
코테공부
문제https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=4&contestProbId=AV15QRX6APsCFAYD&categoryId=AV15QRX6APsCFAYD&categoryType=CODE&problemTitle=&orderBy=INQUERY_COUNT&selectCodeLang=ALL&select-1=4&pageSize=10&pageIndex=1 SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.comN*N차원의 배열이 주어질때, S에서 G로 가는 가장 작은 가중치를 찾는 문제이다.   풀이BFS기반의 다익스트라로 풀었다.num_m..
[SW Expert Academy] 1244. [S/W 문제해결 응용] 2일차 - 최대 상금
·
코테공부
🫠문제https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV15Khn6AN0CFAYD&categoryId=AV15Khn6AN0CFAYD&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1 SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com숫자들의 주어진 수 만큼 교환하여 가장 큰수를 만드는 문제이다  😎풀이백트레킹으로 해결했다(해당 회차, 숫자리스트) 로 visited 여부를 확인하..
1206. [S/W 문제해결 기본] 1일차 - View
·
코테공부
문제https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV134DPqAA8CFAYh SW Expert AcademySW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!swexpertacademy.com   풀이for test_case in range(1, 11): n = int(input()) height=list(map(int,input().split())) num_house=0 for j in range(2,n-2): left=max(height[j-2],height[j-1]) right=max(height[j+1],height[j+2]) ..
[OpenCV] findContours | 이미지 윤곽선 검출
·
Internship
🐹이미지 윤곽선이란?윤곽선은 이미지 내 객체의 외각경계를 말한다. https://docs.opencv.org/4.x/d4/d73/tutorial_py_contours_begin.html OpenCV: Contours : Getting StartedNext Tutorial: Contour Features Goal What are contours? Contours can be explained simply as a curve joining all the continuous points (along the boundary), having same color or intensity. The contours are a useful tool for shape analysis and object detectidoc..
파이썬 백준 1941번: 소문난 칠공주
·
Algorithm/python 백준
문제https://www.acmicpc.net/problem/1941   👸풀이DFS로는 십자모양으로 탐색할수 없다. 따라서 조합할 수 있는 모든 경우를 만들어 놓고, 이들의 조건이 문제와 맞는지 확인했다. 정답 조건은 아래와 같다. 1. 모든 원소가 인접해 있을 것2. 원소의 수가 7일것2. 이다솜파가 4명이상일것 from itertools import combinationsfrom collections import dequeimport sysprincess=[]answer=0for _ in range(5): temp=list(sys.stdin.readline().strip()) princess.append(temp)dx=[-1,1,0,0]dy=[0,0,-1,1]positions = [(i..
파이썬 백준 15654번: N과 M (5)
·
Algorithm/python 백준
문제 https://www.acmicpc.net/problem/15654 15654번: N과 M (5) N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 www.acmicpc.net 풀이 백트래킹으로 해결했다. import sys def backtracking(): if len(num)==M: print(" ".join(map(str,num))) return for i in num_list: if i not in num: num.append(i) backtracking() num.pop() N,M=map(int, sys.stdin.readline().split(..
파이썬 백준 15649번: N과 M (1)
·
Algorithm/python 백준
문제 https://www.acmicpc.net/problem/15649 15649번: N과 M (1) 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. 수열은 사전 순으로 증가하는 순서로 출력해 www.acmicpc.net 풀이 백트레킹으로 해결했다. import sys def backtracking(): if len(num)==M: print(" ".join(map(str,num))) return for i in range(1,N+1): if i not in num: num.append(i) backtracking() num.pop() N,M=map(int, sys.stdin.readline().split(..
파이썬 백준 6603번: 로또
·
Algorithm/python 백준
문제 https://www.acmicpc.net/problem/6603 6603번: 로또 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있다. 첫 번째 수는 k (6 < k < 13)이고, 다음 k개 수는 집합 S에 포함되는 수이다. S의 원소는 오름차순으로 www.acmicpc.net 풀이 num_list에 문자를 입력받는다. num을 로또번호가 들어가는 리스트로 정의한다. num_list에 있는 문자를 순회하며 조건의 맞는경우 num에 추가한다. import sys def backtracking(): if len(num)==6: print(" ".join(map(str,num))) return for i in num_list: if i not in num: i..
파이썬 백준 1629번: 곱셈
·
Algorithm/python 백준
문제 https://www.acmicpc.net/problem/1629 1629번: 곱셈 첫째 줄에 A, B, C가 빈 칸을 사이에 두고 순서대로 주어진다. A, B, C는 모두 2,147,483,647 이하의 자연수이다. www.acmicpc.net 풀이 분할정복을 이용해서 풀었다. B가 짝수일때 , A^B = A^(B/2) * A^(B/2) 이다. B가 홀수일때, A^B= A^(B/2) * A^(B/2) * A 이다. import sys def fast_power(base, exponent, modulus): result = 1 base %= modulus while exponent > 0: # 지수가 홀수인 경우 if exponent % 2 == 1: result = (result * base) %..
파이썬 백준 2644번 : 촌수계산 - BFS, DFS
·
Algorithm/python 백준
문제 https://www.acmicpc.net/problem/2644 2644번: 촌수계산 사람들은 1, 2, 3, …, n (1 ≤ n ≤ 100)의 연속된 번호로 각각 표시된다. 입력 파일의 첫째 줄에는 전체 사람의 수 n이 주어지고, 둘째 줄에는 촌수를 계산해야 하는 서로 다른 두 사람의 번호가 주어 www.acmicpc.net 풀이 key : 방문을 True, False로 기록하는 보통의 visited리스트를 각각의 촌수를 넣는 리스트로 변경하여 결과를 출력한다 1. 처음 입력받은 target1(x)을 기준으로 촌수를 저장하는 리스트를 visited로 정의한다. 2. 방문하지 않은 노드를 visited=-1로 초기화한다. 3. 처음 방문시 이전의 촌수에 1을 더하여 업데이트한다. 4. visit..
✿(๑❛ڡ❛๑)✿
'알고리즘' 태그의 글 목록