728x90
https://www.acmicpc.net/problem/16180
16180번: New House
Johan wants to build a new house and he wants his house as large as it can. Given an N x N grid land, find the largest square size that fit in the free area.
www.acmicpc.net
ICPC > Regionals > Asia Pacific > Indonesia > Indonesia National Contest > INC 2009 F번
적당한 난이도의 문제였던 것 같다.
영어라 그런지 푼 사람이 적었다.
여러가지 놓친 부분들이 많아서 3번이나 틀렸다.
앞으로는 문제에서 놓친 부분은 없을지 잘 확인해보자.
#include <iostream>
using namespace std;
char arr[11][11];
int t, n, cnt;
int boooool() {
int f = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (arr[i][j] == '#') f = 1;
}
}
return f;
}
int S12(int size, int x, int y) {
for (int i = x; i < x + size; i++) {
for (int j = y; j < y + size; j++) {
if (i >= n || j >= n) return 0;
if (arr[i][j] == '#') return 0;
}
}
return 1;
}
int S(int x, int y) {
for (int i = 1; i <= n; i++) {
if (S12(i, x, y)) continue;
else return i - 1;
}
return 1;
}
int main() {
int max;
cin >> t;
while (t--) {
max = 0;
cin >> n;
for (int i = 0; i < n; i++)
cin >> arr[i];
if (boooool()) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (arr[i][j] == '.') {
cnt = S(i, j);
max = cnt > max ? cnt : max;
}
}
}
}
else max=n;
cout << max << '\n';
}
}
728x90
'알고리즘 > 문제' 카테고리의 다른 글
[codeground] Practice. 2. 프로그래밍 경진대회 (0) | 2020.08.22 |
---|---|
[codeground] Practice. 1. 숫자 골라내기 (0) | 2020.08.21 |
[백준] 1920. 수 찾기 <C++> (0) | 2020.07.28 |
[백준] 6588. 골드바흐의 추측 <C++> (0) | 2020.07.21 |
구름 문제은행 (시공의 폭풍 속으로) <C++> (0) | 2020.07.17 |
댓글