software engineering

software engineering/PS

boj 16724

#include using namespace std; int N, M; string grid[1001]; int visited[1001][1001]; int ret = 0; char getGrid(int y, int x) { return grid[y][x]; } void dfs(int y, int x, int num) { if (y>=0 && x>=0 && y N >> M; for(int i=0;i> grid[i]; } int cnt = 0;//cnt != ret for (int i=0;i

software engineering/PS

boj 2225 (top-down & bottom-up)

// top-down과 bottom-up 감을 찾을 수 있는 좋은 베이직한 문제 // 두 방식 모두로 풀이가 가능하다. // top down #include #include using namespace std; int N, K; long long dp[201][201]; long long sumCnt(int n, int k) { if (n==0) return 1; if (k==1) return 1; if (dp[n][k]) return dp[n][k]; for (int i=0;i> N >> K; memset(dp, 0, sizeof(dp)); cout > n >> k; memset(dp, 0, sizeof(dp)); for (int i=0;i 0 0 0 여기 끝에 6붙여서 0 0 0 6 만들면 경우의 수..

software engineering/PS

boj 7569

#include #include using namespace std; int graph[100][100][100]; //rch int dir[6][3]{ {1,0,0},{0,1,0},{-1,0,0},{0,-1,0},{0,0,1},{0,0,-1} }; int R, C, H; int ret = 1; queue q; void bfs() { while (!q.empty()) { int size = q.size(); for (int i = 0; i < size;i++) { int r = q.front().first.first; int c = q.front().first.second; int h = q.front().second; q.pop(); for (int j = 0; j < 6; j++) { int nr =..

software engineering/PS

boj 10800

#include #include using namespace std; int n; int C[200020],S[2020]; pair arr[200020]; int ans[200020]; int main() { scanf(" %d", &n); for (int i = 0; i < n; i++) { int w, c; scanf(" %d %d", &c, &w); arr[i] = { {w,c-1},i }; } sort(arr, arr + n); int sum = 0; for (int i = 0; i < n; i++) { int weight = arr[i].first.first; int color = arr[i].first.second; int idx = arr[i].second; C[color] += weight..

software engineering/PS

boj 1912

#include #include #include using namespace std; // 누적합 문제 int N; int dp[100001]; // dp[i]는 i번 수를 무조건 사용하는 최대 연속합 int arr[100001]; // 수열 int ret = INT_MIN; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; for(int i=1;i> arr[i]; dp[i] = max(dp[i-1]+arr[i], arr[i]); ret = max(ret, dp[i]); } cout

software engineering/PS

boj 12851

주요 포인트: 1) 입력이 1 4 일 경우 1*2와 1+1을 다른 경우로 구분해야 하기 때문에 visited를 true로 바꿔주는 시점이 큐에서 pop을 한 이후가 되야 한다. 2) 턴수를 기록하기 위해서 queue를 사용하면 편하고, 다른 사람들 풀이도 대부분 이러한 형태이다. 그러나 더 까다롭지만 배열을 써도 풀 수 있다. 이를 위해선 한 번 이동할 때 최대크기 체크( N >> K; memset(turns, 0, sizeof(turns)); memset(visited, false, sizeof(visited)); bfs(); cout

software engineering

자료구조/정렬 BigO 표

https://www.bigocheatsheet.com/ Big-O Algorithm Complexity Cheat Sheet (Know Thy Complexities!) @ericdrowell Know Thy Complexities! Hi there! This webpage covers the space and time Big-O complexities of common algorithms used in Computer Science. When preparing for technical interviews in the past, I found myself spending hours crawling the internet putting t www.bigocheatsheet.com

software engineering/PS

boj 14891

deque를 사용 #include #include #include #include #include using namespace std; vector gear(5); int rotation[5]; bool check[5]; int k; void setRotation(int g, int d) { rotation[g] = d; check[g] = true; if (g - 1 > 0 && !check[g - 1]) { if (d == 0) setRotation(g - 1, 0); else if (gear[g][6] == gear[g - 1][2]) setRotation(g - 1, 0); else setRotation(g - 1, -d); } if (g + 1 k; int g, d; while (k--) { c..