본문 바로가기

반응형

Algorithm_프로그래머스

(16)
[프로그래머스 42583 c++ VO] 다리를 지나는 트럭 - 풀이 링크: https://github.com/xhaktmchl/Algorithm_study/blob/main/Programmers/%EC%9E%90%EB%A3%8C%EA%B5%AC%EC%A1%B0/%5B%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%2042583%20c%2B%2B%20VO%5D%20%EB%8B%A4%EB%A6%AC%EB%A5%BC%20%EC%A7%80%EB%82%98%EB%8A%94%20%ED%8A%B8%EB%9F%AD.cpp GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이 알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study developme..
[프로그래머스 42839 c++ VV] 소수 찾기 - 풀이 링크: https://github.com/xhaktmchl/Algorithm_study/blob/main/Programmers/%EC%99%84%EC%A0%84%ED%83%90%EC%83%89/%5B%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%2042839%20c%2B%2B%20VV%5D%20%EC%86%8C%EC%88%98%20%EC%B0%BE%EA%B8%B0.cpp GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이 알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub. gi..
[프로그래머스 1845 c++ OO] 폰켓몬 - 풀이 링크: https://github.com/xhaktmchl/Algorithm_study/blob/main/Programmers/%ED%95%B4%EC%8B%9C/%20%5B%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%201845%20c%2B%2B%20OO%5D%20%ED%8F%B0%EC%BC%93%EB%AA%AC GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이 알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub. github.com #include #include #incl..
[프로그래머스 42578 c++ VV] 위장 - 풀이 링크: https://github.com/xhaktmchl/Algorithm_study/blob/main/Programmers/%ED%95%B4%EC%8B%9C/%5B%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4%2042578%20c%2B%2B%20VV%5D%20%EC%9C%84%EC%9E%A5.cpp GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이 알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub. github.com #include #include #include #in..
[프로그래머스 c++ X] 여행경로 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 32 33 34 35 36 37 38 39 40 #include #include #include using namespace std; // [프로그래머스 c++ X] 여행경로 // 문제: // 접근: // 풀이: // 주의: 노드가 서로 이어지지 않은 경우 처리하는 것 주의 #define MAX 10001 bool visit[MAX]; vector answer; bool ok; void dfs(string start,vector& tickets,vector tp,int cnt){ // 현재 공항,티켓배열,현째까지 경로, 경로에 포함된 노드갯수 // 경로를 ..
[프로그래머스 c++ O] 타겟 넘버 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 32 33 34 #include #include using namespace std; // [프로그래머스 c++ O] 타겟 넘버 // 문제: 주어진 숫자를 더하거나 빼서 원하는 값이 나오는 경우의 수 구하기 // 접근: 더하거나 빼는 모든 경우 -> 완탐 재귀 1.더한경우, 2.뺀경우 // 시간복잡도: O(2^20) = 100만 // 풀이: // 재귀로 완탐(숫자배열의 인덱스, 합) 인자 // 종료조건: 모든 숫자 계산완료되면 // 더한경우 뺀경우 재귀 int tar,n,cnt=0; vector number; void re(int idx,int sum){ ..
[프로그래머스 c++ O] 네트워크 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 32 33 34 35 36 37 38 #include #include using namespace std; // [프로그래머스 c++ O] 네트워크 // 문제: 컴퓨터들의 네트워크 갯수 구하기 = 그래프의 연결요소 구하기 // 접근: 그래프의 연결요소 구하기 -> dfs // 시간복잡도: O(정점+ 간선의 갯수) = n+ (n-1)*n/2 // 풀이: // 1차원 노드완탐 방문 하지 않았으면 -> dfs, 네트워크갯수 증가 // dfs에서 방문처리,자신노드예외, 방문하지 않고 간선있으면 해당노드와 연결된 모든 노드 탐색 #define MAX 201 bool..
[프로그래머스 c++ V] 단체사진 찍기 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 #include #include #include #include using namespace std; // [프로그래머스 c++ V] 단체사진 찍기 // 문제: 8명의 멤버가 있을 때 문자열로 주어지는 조건에 맞는 순열의 수 구하기 // 접근: 완전탐색: 8명이 줄스는 경우의 수 -> next_permutation() 이용 모든 순열 탐색 // 멤버 사이 거리는 string.find() 함수 이용 // 시간복잡도: O(n*순열의 수) = 100*8! = 약 40..

반응형