title: "N과 M (2)(15650)" category: 백준[Class-4] tags: [C++, JavaScript, 백준] date: "2021-05-27" 문제 링크 N과 M (2)(15650) C++ #include #include #include using namespace std; void doCombination(vector& origin, vector& selected, int select, int start){ if(select == 0){ for(int i=0; i i + 1); const result = doCombi(origin, +m); console.log(result.map((v) => v.join(" ")).join("\n"));
title: "이중 우선순위 큐(7662)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-25" 문제 링크 이중 우선순위 큐(7662) C++ #include #include #include #include using namespace std; // 문제 풀이 void solution(){ int t; cin >> t; for(int i=0; i> k; multiset ms; for(int i=0; i> op >> num; if(op=='I'){ ms.insert(num); } else if(op=='D'){ if(ms.empty()) continue; if(num==1){ // 최댓값 삭제 ms.eras..
title: "AC(5430)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-24" 문제 링크 AC(5430) C++ #include #include #include #include #include using namespace std; void solution(){ int t; cin >> t; for(int i=0; i> p; // Init 개수 int size; cin >> size; // Init 배열 string arr; cin >> arr; arr = arr.substr(1, arr.length()-2); stringstream ss(arr); string res; while(getline(ss, res, ','..
title: "토마토(7576)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-23" 문제 링크 토마토(7576) C++ #include #include #include #include using namespace std; void solution(){ int m, n; cin >> m >> n; // Init vector board; for(int i=0; i num; vec.push_back(num); } board.push_back(vec); } // Push 익은 토마토 queue q; for(int y=0; y
title: "숨바꼭질(1697)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-23" 문제 링크 숨바꼭질(1697) C++ #include #include #include #include using namespace std; void solution(){ int n, k; cin >> n >> k; const int limit = 100000; vector visited(limit+1, false); queue q; q.push({n, 0}); visited[n]=true; while(!q.empty()){ int current = q.front().first; int time = q.front().second; q.pop(); /..
title: "Z(1074)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-23" 문제 링크 Z(1074) C++ #include #include #include using namespace std; int n, r, c; int mark; void divide(int size, int row, int col){ if(r==row && c==col){ // 원하는 위치 cout r >> c; int size = 1 { if (r === row && c === col) { // 위치 찾음. console.log(mark); } else if (r >= row && r = col && c < col + ..
title: "좌표 압축(18870)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-22" 문제 링크 좌표 압축(18870) C++ #include #include #include #include #include using namespace std; int doBst(vector& vec, int target){ int left = 0; int right = vec.size()-1; while(left < right){ int mid = (left + right) / 2; if(vec[mid] == target){ left = mid; break; } else if(vec[mid] < target){ left = mid+1; } el..
title: "최소 힙(1927)" category: 백준[Class-3] tags: [C++, JavaScript, 백준] date: "2021-05-21" 문제 링크 최소 힙(1927) C++ #include #include #include #include using namespace std; typedef unsigned int uint; void solution(){ int n; cin >> n; priority_queue pq; for(int i=0; i> x; if(x>0){ pq.push(x); } else { if(!pq.empty()){ cout