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

推荐订阅源

PCI Perspectives
PCI Perspectives
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
T
The Blog of Author Tim Ferriss
罗磊的独立博客
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
Engineering at Meta
Engineering at Meta
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
Recent Announcements
Recent Announcements
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
The GitHub Blog
The GitHub Blog
M
MIT News - Artificial intelligence
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
V
Visual Studio Blog
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
AI
AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Security Affairs
S
SegmentFault 最新的问题
C
Cisco Blogs
博客园 - 聂微东
MyScale Blog
MyScale Blog
V
Vulnerabilities – Threatpost
量子位
T
The Exploit Database - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Security Latest
Security Latest
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Troy Hunt's Blog
T
Tailwind CSS Blog
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog

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