[BOJ] 14925 목장 건설하기

Time Lapse :8min 23sec

14925.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int map[1000][1000];
int N, M, answer;
bool check(int y, int x){
if(y+answer>=N||x+answer>=M) return false;
for(int i = y; i <= y+answer; ++i)
for(int j = x; j <= x+answer; ++j)
if(map[i][j]) return false;
return true;
}
int main() {
scanf("%d %d",&N,&M);
for(int i = 0; i < N; ++i)
for(int j = 0; j < M; ++j)
scanf("%d",&map[i][j]);
for(int i = 0; i < N-answer; ++i)
for(int j = 0; j < M-answer;++j)
while(check(i,j)) ++answer;
printf("%d",answer);
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/23/PS/BOJ/14925/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.