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

推荐订阅源

H
Hacker News: Front Page
博客园 - 【当耐特】
量子位
博客园 - 聂微东
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Register - Security
The Register - Security
Last Week in AI
Last Week in AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
雷峰网
雷峰网
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
Jina AI
Jina AI
The Cloudflare Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AWS News Blog
AWS News Blog
L
LINUX DO - 最新话题
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Schneier on Security
Stack Overflow Blog
Stack Overflow Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Engineering at Meta
Engineering at Meta
W
WeLiveSecurity
博客园 - 三生石上(FineUI控件)
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
T
Troy Hunt's Blog
C
CERT Recently Published Vulnerability Notes
N
News and Events Feed by Topic
S
SegmentFault 最新的问题
美团技术团队
C
CXSECURITY Database RSS Feed - CXSecurity.com
人人都是产品经理
人人都是产品经理
SecWiki News
SecWiki News
N
News and Events Feed by Topic
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
宝玉的分享
宝玉的分享
Schneier on Security
Schneier on Security
阮一峰的网络日志
阮一峰的网络日志
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
J
Java Code Geeks

博客园 - 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);
  }
}