알고리즘/programmers10 프로그래머스 - 행렬 테두리 회전하기 #include #include #include using namespace std; vector board; int c; int dx[] = {1,0,-1,0}; int dy[] = {0,1,0,-1}; int r(vector q) { int dir = 0; int sy = q[0] - 1; int sx = q[1] - 1; int ey = q[2] - 1; int ex = q[3] - 1; int cy = sy + dy[dir]; int cx = sx + dx[dir]; int t = board[sy][sx]; int ans = c; while (1) { ans = min(ans, t); swap(t, board[cy][cx]); if (cy == sy && cx == sx) { break; } if.. 2021. 10. 9. 2019 KAKAO BLIND RECRUITMENT / 길 찾기 게임 2019 KAKAO BLIND RECRUITMENT 길 찾기 게임 #include #include #include using namespace std; class Node { public: int n; Node* l; Node* r; int x; int y; }; void make(Node* r, Node* n) { if (n->x x) { if (!r->l) { r->l = n; return; } make(r->l, n); return; } if (!r->r) { r->r = n; return; } make(r->r, n); } void dfs(Node* r, vector &v) { if (!r) return; v.push_back(r->n + 1); dfs(r->l, v); dfs(r->r,.. 2021. 9. 19. 이전 1 2 3 다음