백준
-
백준 13460번 C++ 코드백준 2020. 1. 15. 00:53
#include #include #include #include #include #include #include #include #include using namespace std; using pii = pair; using tiiii = tuple; int n, m; bool isVisited[10][10][10][10]; int dp[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; char buffer[10][10]; bool hasRoute = false; int answer = INT_MAX; queue q; struct Element { int redX; int redY; int blueX; int blueY; }; bool isInside(int x, int y)..
-
백준 17370번 풀이백준 2019. 12. 3. 00:28
육각형 형태를 좌표평면에 대응시킵니다. 입력 제한이 22이므로... 아무리 멀리 나가더라도 상하좌우로 50을 벗어날 수 없겠죠. 버퍼를 50*50으로 받고... DFS로 백트래킹해서 답을 구해냅니다. 시간복잡도는 O(2^n) #include #include #include #include #include #include #include #include using namespace std; struct Point { int x; int y; int previousX; int previousY; bool type; vector nextPoints() { vector candidate; if (type) { int delta[3][2] = { {-1, 0}, {1, 1}, {1, -1} }; for (auto..
-
백준 16681번 풀이백준 2019. 12. 1. 21:05
#include #include #include #include #include #include #include #include #define MAX 987654321 using namespace std; class ClimbManager { public: ClimbManager(long long n, long long d, long long e) { this->n = n; this->d = d; this->e = e; this->heights = new long long[n]; this->buffer = new vector[n]; this->mountainBuffer = new vector[n]; this->univercityBuffer = new vector[n]; } void setHeight(lo..
-
PS(알고리즘) 오픈 톡방 신입부원 대 모집!!백준 2019. 12. 1. 00:24
하루에 한 문제씩 PS 문제를 즐겁게 푸는 모임을 가져보고자 오픈채팅방을 만들었어요!! 그렇게 어렵지는 않은 백준 문제 하나 혹은 (예시 : https://www.acmicpc.net/problem/14619) 난이도가 쉬우나 알고리즘 지식이 탄탄해야 하는 릿코드 문제 둘 (예시: https://leetcode.com/problems/cells-with-odd-values-in-a-matrix/) 정도를 매일 선정할 거에요. 자신의 실력과 취향에 맞추어서 하루에 한 문제 혹은 두 문제씩 풀고, 코드를 서로 올려보면서 PS를 즐겨보아요 ★★ 규칙은 아래 노션에 올려놓았어요 !! https://www.notion.so/PS-da8977089c2344dba9bdbc3d0188d286 익명 톡방이고 하루이틀 문..
-
백준 14619번 c++ 풀이백준 2019. 11. 24. 12:04
#include #include #include #include #include #include #include #include using namespace std; class IslandManager { public: IslandManager(int n) { this->n = n; this->bridgeBuffer = new bool*[n]; this->heightBuffer = new int[n]; for (auto i=0; ibridgeBuffer[i] = new bool[n] {false} ; } } void setHeight(int index, int height) { this->heightBuffer[index]=height; } void setBridge(int to, int from) { ..
-
백준 14612번 C++ 풀이백준 2019. 11. 21. 23:19
#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; struct PostIt { int tableNumber; int orderTime; PostIt(int tableNumber, int orderTime) { this->tableNumber = tableNumber; this->orderTime = orderTime; } }; inline bool compare(const PostIt& lhs, const PostIt& rhs) { if (lhs.orderTime == rhs.orderTime) { return..
-
백준 13413번 C++ 풀이백준 2019. 11. 9. 23:30
#include #include #include #include #include #include #include #include using namespace std; bool buffer[100][100]; int answer(bool origin[], bool goal[], int n) { int white = 0; int black = 0; for (auto i=0; i> t; while (t--) { int n; cin >> n; bool origin[n]; bool goal[n]; for (auto i=0; i> temp; origin[i] = temp == 'W'; } for (auto i=0; i> temp; goal[i] = temp == 'W'; } cout
-
백준 2096번 C++ 풀이백준 2019. 10. 29. 00:28
#include #include #include #include #include using namespace std; int main() { int n; cin >> n; int buffer[3] = {0, 0, 0}; int previousMinAnswer[3] = {0, 0, 0}; int minAnswer[3] = {0, 0, 0}; int previousMaxAnswer[3] = {0, 0, 0}; int maxAnswer[3] = {0, 0, 0}; for (auto i=0; i buffer[j]; } minAnswer[0] = buffer[0] + min(previousMinAnswer[0], previousMinAnswer[1]); minAnswer[1] = buffer[1] + min(mi..