목록Problem Solving (223)
Life Engineering
https://www.acmicpc.net/problem/15654 15654번: N과 M (5) N개의 자연수와 자연수 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. N개의 자연수는 모두 다른 수이다. N개의 자연수 중에서 M개를 고른 수열 www.acmicpc.net #include #include #include using namespace std; vector v; vector ans; int N, M, x; bool check[9] = { false, }; void dfs(int cnt, vector &c) { if (cnt == M) { ans.push_back(c); return; } for (int i = 0; i < N; i++) { if..
https://programmers.co.kr/learn/courses/30/lessons/42587 코딩테스트 연습 - 프린터 일반적인 프린터는 인쇄 요청이 들어온 순서대로 인쇄합니다. 그렇기 때문에 중요한 문서가 나중에 인쇄될 수 있습니다. 이런 문제를 보완하기 위해 중요도가 높은 문서를 먼저 인쇄하는 프린 programmers.co.kr #include #include #include using namespace std; int solution(vector priorities, int location) { int answer = 0; queue q; priority_queue pq; for (int i=0; i
https://www.acmicpc.net/problem/21609 21609번: 상어 중학교 상어 중학교의 코딩 동아리에서 게임을 만들었다. 이 게임은 크기가 N×N인 격자에서 진행되고, 초기에 격자의 모든 칸에는 블록이 하나씩 들어있고, 블록은 검은색 블록, 무지개 블록, 일반 블록 www.acmicpc.net #include #include #include #include #include using namespace std; int dx[4] = { -1,1,0,0 }; int dy[4] = { 0,0,-1,1 }; struct blockGroup { vector members; int num_rainbow; pair standard_block; bool operator b.standard_bloc..
https://programmers.co.kr/learn/courses/30/lessons/42746?language=cpp# 코딩테스트 연습 - 가장 큰 수 0 또는 양의 정수가 주어졌을 때, 정수를 이어 붙여 만들 수 있는 가장 큰 수를 알아내 주세요. 예를 들어, 주어진 정수가 [6, 10, 2]라면 [6102, 6210, 1062, 1026, 2610, 2106]를 만들 수 있고, 이중 가장 큰 programmers.co.kr #include #include #include using namespace std; struct{ bool operator()(string a, string b) const{ return a+b>b+a; } } cmp; string solution(vector number..