[BOJ] 1915번 : 가장 큰 정사각형
2024. 9. 4. 08:37ㆍAlgorithm
1. problem :
https://www.acmicpc.net/problem/1915
2 .solution1 :
#include <bits/stdc++.h>
using namespace std;
int n, m;
int board[1005][1005], d[1005][1005];
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
string s;
cin >> s;
for (int j = 1; j <= s.length(); j++) {
board[i][j] = (s[j-1] - '0');
}
}
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (board[i][j]) d[i][j] = min({ d[i - 1][j],d[i][j - 1],d[i - 1][j - 1] }) + 1;
ans = max(ans, d[i][j]);
}
}
cout << ans * ans;
}
source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/0x10/solutions/1915.cpp
basic-algo-lecture/0x10/solutions/1915.cpp at master · encrypted-def/basic-algo-lecture
바킹독의 실전 알고리즘 강의 자료. Contribute to encrypted-def/basic-algo-lecture development by creating an account on GitHub.
github.com
'Algorithm' 카테고리의 다른 글
[BOJ] 9655번 : 돌 게임 (0) | 2024.09.05 |
---|---|
[BOJ] 10942번 : 팰린드롬? (0) | 2024.09.05 |
[BOJ] 9084번 : 동전 (0) | 2024.09.04 |
[BOJ] 1699번 : 제곱수의 합 (0) | 2024.09.03 |
[BOJ] 9251번 : LCS (0) | 2024.09.03 |