码迷,mamicode.com
首页 > 其他好文 > 详细

[USACO5.3]巨大的牛棚Big Barn

时间:2019-09-15 01:15:06      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:problem   https   div   col   std   big   表示   ace   include   

[TimeGate]

https://www.luogu.org/problem/P2701

【解题思路】

f[i][j]=min(min(f[i][j-1],f[i-1][j]),f[i-1][j-1])+1;

f(i, j)表示以(i, j)为右下角的最大正方形的边长。

【code】

 1 #include <cstdio>
 2 #include <iostream>
 3 #include <algorithm>
 4 using namespace std;
 5 int n,t,x,y,ans=-1<<29; 
 6 bool vis[1005][1005];
 7 int f[1005][1005];
 8 int main(){
 9     //freopen("2701.in","r",stdin);
10     //freopen("2701.out","w",stdout);
11     scanf("%d%d",&n,&t);
12     while(t--){
13         scanf("%d%d",&x,&y); 
14         vis[x][y]=true;
15     }
16     for(register int i=1;i<=n;i++){
17         for(register int j=1;j<=n;j++){
18             if(!vis[i][j])
19                 f[i][j]=min(f[i-1][j-1],min(f[i][j-1],f[i-1][j]))+1;
20             ans=max(ans,f[i][j]);
21         }
22     }
23     printf("%d\n",ans);
24     return 0;
25 }

 

[USACO5.3]巨大的牛棚Big Barn

标签:problem   https   div   col   std   big   表示   ace   include   

原文地址:https://www.cnblogs.com/66dzb/p/11520754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!