본문 바로가기

분류 전체보기

(370)
[BOJ] 7490번 0 만들기 (C++) https://www.acmicpc.net/problem/7490 7490번: 0 만들기 각 테스트 케이스에 대해 ASCII 순서에 따라 결과가 0이 되는 모든 수식을 출력한다. 각 테스트 케이스의 결과는 한 줄을 띄워 구분한다. www.acmicpc.net #include #include #include using namespace std; int n; bool isZero(string s){ vector num; vector op; string tmp; for(int i = 0; i < s.length(); i++){ if(s[i] == '+' || s[i] == '-'){ num.push_back(stoi(tmp)); op.push_back(s[i]); tmp = ""; } else if(s[i] ..
[BOJ] 19942번 다이어트 (C++) https://www.acmicpc.net/problem/19942 19942번: 다이어트 식재료 N개 중에서 몇 개를 선택해서 이들의 영양분(단백질, 탄수화물, 지방, 비타민)이 일정 이상이 되어야 한다. 아래 표에 제시된 6가지의 식재료 중에서 몇 개를 선택해서 이들의 영양분의 각 www.acmicpc.net #include #include using namespace std; struct Ingredient{ int p, f, s, v, c; }; int n, mp, mf, ms, mv; vector v; vector tmp; vector ans; int answer = 987654321; void dfs(int idx, int sp, int sf, int ss, int sv, int sc){ if..
[CodeTree] 나무박멸 (C++) [삼성 SW 역량테스트 기출] https://www.codetree.ai/training-field/frequent-problems/problems/tree-kill-all 코드트리 | 코딩테스트 준비를 위한 알고리즘 정석 국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요. www.codetree.ai #include using namespace std; int n, m, k, c, answer; int map[20][20]; int dx1[4] = {0, 0, -1, 1}; int dy1[4] = {-1, 1, 0, 0}; int dx2[4] = {-1, -1, 1, 1}; int dy2[4] = {-1, 1, -1, 1}; void Growth(){ for(..
[CodeTree] 바이러스 백신 (C++) [삼성 SW 역량테스트 기출] https://www.codetree.ai/training-field/frequent-problems/problems/vaccine-for-virus 코드트리 | 코딩테스트 준비를 위한 알고리즘 정석 국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요. www.codetree.ai #include #include #include #include #include using namespace std; int n, m, answer = 987654321; int map[50][50]; int tmp[50][50]; int visited[50][50]; vector hospital; vector picked; bool isUsed[10]; ..
[CodeTree] 방화벽 설치하기 (C++) [삼성 SW 역량테스트 기출] https://www.codetree.ai/training-field/frequent-problems/problems/firewall-installation 코드트리 | 코딩테스트 준비를 위한 알고리즘 정석 국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요. www.codetree.ai #include #include #include #include using namespace std; int n, m, answer; int map[8][8]; int tmp[8][8]; bool isUsed[64]; int dx[4] = {-1, 0, 0, 1}; int dy[4] = {0, -1, 1, 0}; vector blank; vector..
[CodeTree] 병원 거리 최소화하기 (C++) [삼성 SW 역량테스트 기출] https://www.codetree.ai/training-field/frequent-problems/problems/min-of-hospital-distance 코드트리 | 코딩테스트 준비를 위한 알고리즘 정석 국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요. www.codetree.ai #include #include #include using namespace std; int n, m, answer = 987654321; int city[50][50]; bool isUsed[13]; vector patient; vector hospital; vector picked; void dfs(int depth, int start){ ..
[CodeTree] 바이러스 검사 (C++) [삼성 SW 역량테스트 기출] https://www.codetree.ai/training-field/frequent-problems/problems/virus-detector 코드트리 | 코딩테스트 준비를 위한 알고리즘 정석 국가대표가 만든 코딩 공부의 가이드북 코딩 왕초보부터 꿈의 직장 코테 합격까지, 국가대표가 엄선한 커리큘럼으로 준비해보세요. www.codetree.ai #include using namespace std; int n, leader, member; int customer[1000001]; long long answer; int main() { cin >> n; for(int i = 0; i > customer[i]; } cin >> leader >> member; for(int i =..
[BOJ] 20055번 컨베이어 벨트 위의 로봇 (C++) [삼성 SW 역량테스트 기출] https://www.acmicpc.net/problem/20055 20055번: 컨베이어 벨트 위의 로봇 길이가 N인 컨베이어 벨트가 있고, 길이가 2N인 벨트가 이 컨베이어 벨트를 위아래로 감싸며 돌고 있다. 벨트는 길이 1 간격으로 2N개의 칸으로 나뉘어져 있으며, 각 칸에는 아래 그림과 같이 1부 www.acmicpc.net #include #include using namespace std; int n, k; deque dq; int answer; int main() { cin >> n >> k; for(int i = 0; i > x; dq.push_back({x, false}); } while(true){ answer++; // 1 int t1 ..