惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
Vercel News
Vercel News
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
Last Week in AI
Last Week in AI
Hugging Face - Blog
Hugging Face - Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
Engineering at Meta
Engineering at Meta
云风的 BLOG
云风的 BLOG

博客园 - saintqdd

hdu 1102 pku 2421 解题报告 pku 2777 Count Color 解体报告 石子合并问题 nkoj1139和乘积最大那题一样. A Tour in Loquat Orchard (FZU 2007 ICPC Qualification Round I tzw) 滑雪 一道经典题,humble number 今天碰到了一个很诡异的题,Alphacode (zoj 2202) 这两天经常碰到dp题,就写了一个0-1背包 实训以来,到这里的次数少了! 郁闷,乘积最大那题WA原来只是因为我用了pow函数引起的! Smith Number POJ强烈推荐50题 JOJ 2391 words POJ 1014 三十分钟掌握STL STL学习小记 POJ1006,中国剩余定理 POJ1003,简单题
最大黑区域
saintqdd · 2007-09-01 · via 博客园 - saintqdd

有点类似于求最大连通图,当然这类问题都有统一的解法,深搜或广搜.

#include<iostream>
const int MAX=101;
int n,m;
int arr[MAX][MAX];
int f[MAX][MAX];
int LP(int i,int j){
  int k,p,max=1;
  if(i<0||j<0||i>=n||j>=m)
    return 0;
  if(arr[i][j]==0)
    return 0;
  f[i][j]=0;
  if((i-1)>=0&&arr[i-1][j]&&f[i-1][j]==-1)
    max+=LP(i-1,j);
  if((i+1)<=n&&arr[i+1][j]&&f[i+1][j]==-1)
    max+=LP(i+1,j);
  if((j-1)>=0&&arr[i][j-1]&&f[i][j-1]==-1)
    max+=LP(i,j-1);
  if((j+1)<=m&&arr[i][j+1]&&f[i][j+1]==-1)
    max+=LP(i,j+1);
  return max;
}
int main(){
  int i,j,max,t;
  while(scanf("%d%d",&n,&m)&&(n||m)){
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
        scanf("%d",&arr[i][j]);
        f[i][j]=-1;
      }
    }
    max=0;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
        t=LP(i,j);
        if(t>max)
          max=t;
      }
    }
    printf("%d"n",max);
  }
}