This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdlib.h> | |
#include<stdio.h> | |
int main(){ | |
int n,arr[20][20],i,j,m,p,q,num; | |
while(scanf("%d",&n)!=EOF){ | |
for(i=0;i<n;i++){ | |
for(j=0;j<n;j++){ | |
scanf("%d",&arr[i][j]); | |
} | |
} | |
scanf("%d",&num); | |
for(m=n;m>0;m--){ | |
for(i=0;i<=n-m;i++){ | |
for(j=0;j<=n-m;j++){ | |
int b=1; | |
for(p=0;p<m;p++){ | |
for(q=0;q<m;q++){ | |
if(arr[p+i][q+j]!=num){ | |
b=0; | |
break; | |
} | |
} | |
} | |
if(b){ | |
goto z ; | |
} | |
} | |
} | |
} | |
z: | |
printf("%d\n",m); | |
} | |
/*題目:[C_AR168-易] 最大方塊區域 | |
作者:1010 | |
時間:西元 2017 年 4 月 */ | |
} |
這題簡單來說就是利用一個mask去罩,從最大值n開始逐一遞減