반응형

문제 출처 :


https://www.acmicpc.net/problem/14925



알고리즘 분석 :


문제 해결에 필요한 사항

1. Dynamic Programming

2. 점화식 세우는 방법


http://www.crocus.co.kr/826


위 링크와 코드가 같고(arr[i][j]가 !arr[i][j]만 다릅니다.) 설명을 적어두었기에 위의 링크를 참조하시면 됩니다.





소스 코드 : 


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
29
30
31
32
33
#include <iostream>
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int DP[1003][1003];
int arr[1003][1003];
int ans;
 
int main()
{
    int n, m;
    scanf("%d %d"&n, &m);
 
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            scanf("%d"&arr[i][j]);
 
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (!arr[i][j])
            {
                DP[i][j] = min({ DP[i - 1][j], DP[i][j - 1], DP[i - 1][j - 1] }) + 1;
                ans = max(DP[i][j], ans);
            }
 
    cout << ans;
    return 0;
}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus


반응형

'Applied > 알고리즘 문제풀이' 카테고리의 다른 글

[10814번] 나이순 정렬  (0) 2018.02.20
[14927번] 전구 끄기  (0) 2018.02.19
[11651번] 좌표 정렬하기 2  (0) 2018.02.19
[10840번] 구간 성분  (0) 2018.02.07
[2257번] 화학식량  (2) 2018.02.06