본문 바로가기
728x90
SMALL

전체 글61

[백준] 11508번 : 2+1 세일 (파이썬) 그리디 알고리즘 문제 (1) 처음 내 코드 (성공) n=int(input()) price=[] cost=0 for _ in range(n): a=int(input()) price.append(a) price.sort(reverse=True) if len(price) 2023. 2. 2.
ROS 기본 프로그래밍 topic ROS에서는 단방향 통신일 때 Topic이라는 메시지 통신을 사용한다. 이때 송신 측을 Publisher, 수신 측을 Subscriber라고 부른다. (1) 패키지 설치 ▪︎ 자동으로 패키지 설치해주는 명령어 ▪︎ 해석 : ros_tutorials_topic이라는 패키지를 만들었는데, 그 패키지는 message_generation, std_msgs, roscpp 패키지와 의존성이 있다. 패키지를 작성할 때 가장 기본적으로 구성되어야 할 폴더와 파일들이 들어가있음. (2) 패키지 설정 파일(package.xml) 수정 ROS의 필수 설정 파일 중 하나인 package.xml은 패키지 정보를 담은 XML 파일로서 패키지 이름, 저작자, 라이선스, 의존성 패키지 등을 기술하고 있다. (3) 빌드 설.. 2023. 1. 29.
백준 1527 파이썬 (1) 처음 내 코드 -> 시간초과 a,b = map(int,input().split()) cnt = 0 s1="4" s2="7" for i in range(a,b+1): s = str(i) bool=True for j in s: if j==s1 or j==s2: continue else: bool=False break if bool==True: cnt+=1 print(cnt) 입력이 1보다 크고, 1,000,000,000보다 작거나 같은 자연수로, 코드 제출하기 버튼을 누르면서도 뭔가 시간초과가 날거 같았다. (2) 문제 해결 후 내 코드 -> product 사용 from itertools import product a,b = map(int,input().split()) cnt = 0 key = [] .. 2023. 1. 25.
[백준] 2178번 : 미로 탐색 (파이썬) 미로탐색 문제로, dfs나 bfs로 푸는 문제이다. 나는 bfs를 이용하여 문제를 해결하였다. 처음 내 코드 from collections import deque a,b = map(int,input().split()) visit = [[0]*b for _ in range(a)] for i in range(a): c = input() for j in range(b): visit[i][j] = int(c[j]) print(visit) #BFS queue = deque() dx = [-1,1,0,0] dy = [0,0,-1,1] length=0 for i in range(a): for j in range(b): if visit[i][j]==1: visit[i][j]=0 queue.append([i,j]) le.. 2023. 1. 23.
[백준] 2583번 : 영역 구하기 (파이썬) import sys from collections import deque a,b,c = map(int,input().split()) visit = [[0]*b for _ in range(a)] dx=[0,0,1,-1] dy=[1,-1,0,0] # visit = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]] for i in range(c): x1,y1,x2,y2 = map(int,input().split()) for i in range(y1,y2,1): for j in range(x1,x2,1): visit[i][j]=1 queue = deque(.. 2023. 1. 22.
BFS DFS DFS (1) 재귀로 호출 (2) stack 사용 (1) (2) 2개 코드 차이 BFS * 참고링크 https://www.youtube.com/watch?v=PMMc4VsIacU https://www.youtube.com/watch?v=xlVX7dXLS64 2023. 1. 22.
320x100
LIST