알고리즘/solved.ac

    [class6] (백준 14725) 개미굴

    HTML 삽입 미리보기할 수 없는 소스 #include #include using namespace std; struct Node { int depth = 0; map m; }; int N; string ChangeStr(string str,int count) { string temp = ""; while (count-- > 1) { temp += "--"; } return temp + str; } Node* AddTree(Node* root, string str, int count) { str = ChangeStr(str, count); if (root->m.find(str) != root->m.end()) { return root->m[str]; } Node* node = new Node(); nod..

    [class4] (백준 2638) 치즈

    HTML 삽입 미리보기할 수 없는 소스 #include #include #include using namespace std; #define MAXNUM 101 struct Pos { int x; int y; }; int arr[MAXNUM][MAXNUM]; int visit[MAXNUM][MAXNUM] = { false }; int countAir[MAXNUM][MAXNUM]; int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 }; int n, m; int result = 0; queue q1; queue q2; vector v; bool IsRange(Pos pos) { if (pos.x >= 1 && pos.y >= 1 && pos.x n >> m; f..

    [class4] (백준 17070) 파이프 옮기기 1

    HTML 삽입 미리보기할 수 없는 소스 #include #include using namespace std; int arr[33][33]; int n; int result = 0; enum currentPipe { a, b, c }; struct Pipe { int x; int y; currentPipe _currentPipe; }; bool isAble(int x, int y, currentPipe way) { if (way == a) { if (arr[y][x + 1]) { return false; } } else if (way == b) { if (arr[y][x + 1] || arr[y + 1][x + 1] || arr[y + 1][x]) { return false; } } else { if (a..

    [class4] (백준 15686) 치킨 배달

    HTML 삽입 미리보기할 수 없는 소스 #include #include using namespace std; int n, m; int arr[51][51]; vector chicken; vector house; pair choiceChicken[13]; int minNum = 50 * 2 * 50; int CalRange(pair a, pair b) { int gap = (a.first > b.first) ? a.first - b.first : b.first - a.first; gap += (a.second > b.second) ? a.second - b.second : b.second - a.second; return gap; } void CalChickenRange() { int sum = 0; fo..

    [class4] (백준 11444) 피보나치 수 6

    HTML 삽입 미리보기할 수 없는 소스 #include using namespace std; struct Matrix { long long num[2][2]; }; long long n; const long long HashNum = 1000000007; long long GetHasingMultiplyResult(long long a, long long b, long long c, long long d) { long long result = ((a % HashNum * b) % HashNum) + ((c % HashNum * d) % HashNum); return result % HashNum; } Matrix multiply(Matrix a, Matrix b) { Matrix result; resul..

    [class4] (백준 2263) 트리의 순회

    HTML 삽입 미리보기할 수 없는 소스 #include using namespace std; const int maxnum = 100001; int postorder[maxnum]; int inorder[maxnum]; int index[maxnum]; void PrintPreorder(int istart, int iend, int pstart, int pend) { if (istart > iend || pstart > pend) return; int rootnum = index[postorder[pend]]; int left = rootnum - istart; int right = iend - rootnum; cout n; for (int i = 1; i > inorder[i]; index[inorde..