http://acm.timus.ru/problem.aspx?space=1&num=1221

算是枚举的 题目意思是必须划出这样的 11011

                  10001

                  00000

                  10001

                  11011

注意中间必须是完整的0,不多不少,旁边的1也是如此 不多不少 才可以

题目很简单 预处理出1的个数 以及以当前0为最低顶角的最大正方形的边长 判断一下1的个数是否满足就可

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
using namespace std;
int a[][],dp[][],sum[][];
int main()
{
int i,j,n,maxz,g;
while(cin>>n)
{
if(!n) break;
memset(sum,,sizeof(sum));
memset(dp,,sizeof(dp));
maxz=;
for(i = ; i <= n ; i++)
for(j = ; j <= n ; j++)
{
cin>>a[i][j];
if(a[i][j]==) dp[i][j] = ;
sum[i][j] = sum[i-][j]+sum[i][j-]-sum[i-][j-];
if(a[i][j]==) sum[i][j]++;
}
for(i = ; i <= n ; i++)
for(j = ; j <= n ;j++)
if(a[i][j]==)
{
int k = (min(dp[i-][j],dp[i-][j-]),dp[i-][j+]);
if(i>=*k+&&a[i-*k][j]==)
dp[i][j] = k+;
else
dp[i][j] = ;
//cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
}
int b[] = {};
b[] = ;
for(i = ; i <= ; i++)
b[i] = b[i-]+*(i-);
for(i =; i <= n ; i++)
for(j = ; j <= n ;j++)
{
if(a[i][j]==)
{
int x=;
for(g = j ; g >= ; g--)
if(a[i][g]==)
break;
else x++;
if(i<*x+||j<*x+) continue;
int s = sum[i][j]-sum[i-*x-][j]-sum[i][j-*x-]+sum[i-*x-][j-*x-];
//if(i==5&&j==5)
//cout<<dp[i][j-x]<<" "<<x<<" "<<sum[i][j]<<endl;
if(dp[i][j-x]==x+&&s==(*x+)*(*x+)-b[x+])
maxz = max(maxz,*x+);
}
}
if(maxz)
cout<<maxz<<endl;
else
puts("No solution");
} return ;
}

ural1221. Malevich Strikes Back!的更多相关文章

  1. ural 1221. Malevich Strikes Back!

    1221. Malevich Strikes Back! Time limit: 1.0 secondMemory limit: 64 MB After the greatest success of ...

  2. SGU 319. Kalevich Strikes Back (线段树)

    319. Kalevich Strikes Back Time limit per test: 0.5 second(s)Memory limit: 65536 kilobytes input: st ...

  3. April Fools Day Contest 2014 H. A + B Strikes Back

    H. A + B Strikes Back time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. codeforces 300E Empire Strikes Back 数论+二分查找

    题意:给定N个数a1,a2,a3...aN,现在要求最小的n满足 n!/(a1!*a2!*...*aN!) 是一个正整数的最小的n. 分析:这题的想法很明确,就是分解a1!*a2!*...*aN!,把 ...

  5. sgu Kalevich Strikes Back

    这道题就是求一个大矩形被n个矩形划分成n+1个部分的面积,这些矩形之间不会相交,可能包含.. #include <cstdio> #include <cstring> #inc ...

  6. SGU 319 Kalevich Strikes Back(线段树扫描线)

    题目大意: n个矩形,将一个大矩形分成 n+1 块.矩形之间不重合,可是包括.求这n+1个矩形的面积 思路分析: 用线段树记录他们之间的父子关系.然后dfs 计算面积. 当给出的矩形上边的时候,就要记 ...

  7. CF300E. Empire Strikes Back

    题目链接(是的我越来越懒了..) 题目大意及数据范围: 数据范围很大.“最小”二字让我们考虑二分,但是上界...不会爆long long让你写高精吧? 我们可以发现,∑ai一定满足条件,所以上界是1e ...

  8. Masquerade strikes back Gym - 101911D (数学)

    Quite often the jury of Saratov SU use the problem "Masquerade" in different practice sess ...

  9. [转载]SystemD strikes again : Unit X.mount is bound to inactive unit

    http://mamchenkov.net/wordpress/2017/11/09/systemd-strikes-again-unit-var-whatever-mount-is-bound-to ...

随机推荐

  1. linux下安装vsftp

    1. yum安装vsftp # yum install vsftpd 2. 配置Vsftpd 安装完之后我们要对它进行配置,才能正常使用.编辑vsftpd的配置文件vi /etc/vsftpd/vsf ...

  2. Lessons learned from manually classifying CIFAR-10

    Lessons learned from manually classifying CIFAR-10 Apr 27, 2011 CIFAR-10 Note, this post is from 201 ...

  3. WPF 与Surface 2.0 SDK 亲密接触 - ScatterView 数据绑定篇

    与我们常用的一些WPF 控件相同,ScatterView 控件也支持数据绑定功能.本篇将演示如何利用ScatterView 绑定Win7 系统中的样例图片,并且每张图片会以独立的ScatterView ...

  4. NET 查找程序集路径(CLR关于Assembly的搜索路径的过程)

    最近在回顾.Net应用程序的执行环境,这里做一个很小的总结,方面以后需要的时候进行查找: CLR必须可以找到正确的Assembly,Net提供了Assembly搜索算法,可以根据.config文件(类 ...

  5. Google NACL 简介

    Back to README Getting Started This page tells you how to install Native Client and run demos, both ...

  6. iOS文件操作

      ];                   NSString *plistPath = [filePath stringByAppendingPathComponent:@"collect ...

  7. Content Providers详解

    今天仔细阅读了一遍Content Providers的官方API文档,总结了一下Android中Content Providers的用法. 各种类型的Content Provider对一个结构化的数据 ...

  8. HDU 2709 Sumsets(递推)

    Sumsets http://acm.hdu.edu.cn/showproblem.php?pid=2709 Problem Description Farmer John commanded his ...

  9. Quant面试准备5本书

    Heard on The Street: Quantitative Questions from Wall Street Job Interviews - Timothy Falcon Crack F ...

  10. $("#id a") - $("#id .c a") = ?

    前沿 这是之前淘宝的一道面试题,题目借用了 jQuery 选择器的语法.大概的意思是,从 #id 元素内选出所有不是 .c 后代的 a 元素,即父元素 #id 内的所有后代元素中,选出不是 .c 后代 ...