출처 : https://www.acmicpc.net/problem/1912 1. dp를 통해 합을 구한다.2. 최대 크기에 유의한다. #include #include using namespace std; #define MAX_N 100001 int i, N;int a[MAX_N], dp[MAX_N], result; void input(){ cin >> N; for (i = 1;i > a[i]; dp[i] = 0; } } void cal(){ dp[0] = 0; result = -1001; for (i = 1;i = a[i]) dp[i] = dp[i - 1] + a[i]; else dp[i] = a[i]; result = max(result, dp[i]); }} int main(){ input(); cal..
출처 : https://www.acmicpc.net/problem/2579 1. dp를 통해 차례로 구한다. #include #include using namespace std; #define MAX_N 301 int i, N;int a[MAX_N], dp[MAX_N], result; void input(){ cin >> N; for (i = 1;i > a[i]; } void cal(){ dp[0] = 0; dp[1] = a[1]; dp[2] = a[1] + a[2]; for (i = 3;i
출처 : https://www.acmicpc.net/problem/1107 1. 완전탐색을 통해 모든 케이스를 체크한다. #include #include using namespace std; #define MAX_ERR 11 int i, j, N, ERR, count1, count2;int a[MAX_ERR], result; void input(){ int aa; cin >> N; cin >> ERR; for (i = 1;i > aa; a[aa] = 1; }} int zari(int n){ int zari = 0; do { n = n / 10; zari++; } while (n > 0); return zari;} bool check(int n){ if (n == 0) { if (a[0] == 1) ret..
출처 : https://www.acmicpc.net/problem/1389 1. 총 N명을 각각 bfs 돌며 합을 구한다.2. 합을 비교하여 출력한다. #include #include #include #include using namespace std; vector a[101];int c[101], d[101], ans[101], t = 1000;int N, M, r1, r2; void BFS(int p){queue q;q.push(p);c[p] = 1;while (!q.empty()){int x = q.front();q.pop();for (int i = 0; i < a[x].size(); i++){int y = a[x][i];if (c[y] == 0){q.push(y);c[y] = 1;d[y] = d[..
출처 : https://www.acmicpc.net/problem/14888 #include using namespace std; int N, a[11], b[4], c[10], ans[2], t, r; int main() {ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 0; i > a[i]; ans[0] = -1e9; ans[1] = 1e9;for (int i = 0; i > r; b[i] = r; while (r--) { c[t++] = i; } }do {r = a[0]; t = 1;for (int i = 0; i < N-1; i++) {if (c[i] == 0)r += a[t..
출처 : https://www.acmicpc.net/problem/14889 #include using namespace std; int N, a[20][20], b[20], s[3]; int main() {ios::sync_with_stdio(false); cin.tie(0); cin >> N; s[2] = 1e9;for (int i = 0; i > a[i][j];for (int i = 0; i < N / 2; i++) b[i] = 1;do {s[0] = 0, s[1] = 0;for (int i = 0; i < N; i++)for (int j = 0; j < N; j++) if (b[i] == b[j]) s[b[i]] += a[..
https://www.acmicpc.net/problem/14502 1. input 값을 받으며 2의 개수 및 좌표와 0의 개수를 저장한다.2. dfs로 전체를 돌며 0인 곳에 3개씩 1로 만든다.3. 3개를 만들고 나면 2의 좌표를 돌며 바이러스를 퍼트리면서 안전영역을 구한다.4. dfs가 끝나면 result에 안전영역 최댓값이 들어있으므로 출력한다. #include #include #include using namespace std; int N, M, cnt0, cnt2, tmp, result;int map[8][8];int v[64][2];bool visited[8][8];bool calvisited[8][8];int dir[4][2] = { {1,0},{-1,0},{0,1},{0,-1} }; vo..
출처 : https://www.acmicpc.net/problem/9205 1. N+2 배열을 만들어 좌표를 저장한다.2. 집에서 시작해서 dfs로 도착지점까지 갈 수 있는지 돈다.3. 도착지점이 true면 반환한다. #include #include #include using namespace std; int N;int arr[103][2];bool visited[103]; bool cal(int x1, int y1, int x2, int y2){return ((abs(x1 - x2) + abs(y1 - y2)) > T;for (int t = 0; t > N;memset(visited, false, sizeof(visited));for (int i = 0; i < N + 2; ..
출처 : https://www.acmicpc.net/problem/2583 1. 입력을 받아 바로 배열에 표시를 한다.2. 비어있는 부분을 dfs를 돈다.3. 총 dfs를 시작한 개수와 넓이를 저장하여 출력한다. #include #include using namespace std; int M, N, K, cnt;int map[100][100];bool visited[100][100];int result[10000];int dir[4][2] = { {0,1},{0,-1},{1,0},{-1,0} }; void dfs(int i, int j){visited[i][j] = true; cnt++;for (int d = 0; d < 4; d++){int nexti = i + dir[d][0]; int nextj =..
문제 출처 : https://www.acmicpc.net/problem/2573 1. 빙산이 있는 한 곳을 시작점으로 지정한다.2. 시작점에서 dfs로 빙산들을 돌며 몇 만큼 줄여야 하는지 저장한다.3. dfs를 돌때 시작점에서부터 갈 수 있는 빙산의 개수를 저장한다.4. dfs가 끝나면 먼저 시작점에서 갈 수 있는 빙산의 개수와 총 빙산의 개수를 비교하여 만약 다르면 시간을 출력한다.5. 빙산을 줄이고 다시 반복한다.6. 총 빙산의 개수가 0이 되면 결국 한 덩어리로 없어진 것이므로 0을 출력한다. #include #include using namespace std; int N, M, result, cnt, bing;int map[300][300];int first[3];int visited[300][..
- Total
- Today
- Yesterday
- DP
- 역량 테스트
- scanf
- 17144
- 팁
- 트렌드
- 17837
- SW Expert Academy
- 미세먼지 안녕!
- 이차원 배열과 연산
- 알고리즘
- 연구소 3
- 시간 복잡도
- hackerrank
- 17140
- 백준
- 17143
- 2018 KAKAO BLIND RECRUITMENT
- 2018 카카오 블라인드 채용
- 새로운 게임 2
- SWEA
- 입출력
- 17779
- 삼성
- boj
- 17142
- 게리맨더링 2
- DFS
- string
- STL
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |